Open
Description
Describe the bug
If one calls to_string( std::stacktrace::current() );
initially from a dynamic library (DLL), then this library fails to unload properly. In particular, global objects it in are not destroyed.
Command-line test case
DLL's code:
#include <iostream>
#include <stacktrace>
__declspec(dllexport) void findStacktrace() {
(void)to_string( std::stacktrace::current() ); //#1
}
struct A {
~A() { std::cout << "~A()\n"; } //this is not executed unless line #1 is commented
} a;
Main module code:
__declspec(dllimport) void findStacktrace();
int main() {
findStacktrace();
}
Full code and project files:
StacktraceDll.zip
Expected behavior
~A()
destructor must be called irrespectively of previous calls to std::stacktrace
.
STL version
Microsoft Visual Studio Community 2022 (64-bit) - Current
Version 17.10.0
Additional context
Please note that to_string( boost::stacktrace::stacktrace() )
works fine in this scenario.