-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Unloaded dll compiled with exception support causes exe to crash on exit #38
Comments
I debugged it a bit more, and I believe that I found the reason for the issue. First, note that it's related to exceptions. Even a dll as simple as the following triggers the crash: #include <vector>
void x()
{
std::vector<int> v;
v.push_back(2);
} As for the root of the problem, it's caused by an The exported Perhaps you can call the CRT's atexit function to fix this. There's the |
Hi @justanotheranonymoususer , Thanks for spending the time to look into this issue! Microsoft's docs state:
We'll probably need to go a bit deeper. |
I think that it's only relevant for static linkage. Dynamic linkage msvcrt.dll can't know who the caller is, since there's only one msvcrt.dll in the process address space. I replaced |
std::mutex
causes exe to crash on exit
The command line switches for the workaround: |
I'm not sure whether the issue is caused by one of the patches or whether it's a GCC bug. There are patches about
std::mutex
, mcrtdll, threads, all potentially related.Reproduction
Create and compile dll.cc as following:
g++.exe dll.cc -shared -o test.dll
Create and compile exe.cc as following:
g++.exe exe.cc -o test.exe
Run test.exe and observe a crash after seeing both message boxes.
The crash happens in
msvcrt.doexit
, which tries to call a cleanup function inside the dll which was already freed.The text was updated successfully, but these errors were encountered: