Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<stacktrace>: unloading fails of a dll that first obtained stacktrace #4855

Open
Fedr opened this issue Jul 22, 2024 · 0 comments
Open

<stacktrace>: unloading fails of a dll that first obtained stacktrace #4855

Fedr opened this issue Jul 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Fedr
Copy link

Fedr commented Jul 22, 2024

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.

@StephanTLavavej StephanTLavavej added the bug Something isn't working label Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants