From: SF/projects/mingw n. l. <min...@li...> - 2012-07-10 20:16:41
|
Bugs item #3542140, was opened at 2012-07-10 12:31 Message generated for change (Comment added) made by jerstlouis You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=3542140&group_id=2435 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: gcc Group: None Status: Closed Resolution: Wont Fix Priority: 5 Private: No Submitted By: Jerome St-Louis (jerstlouis) Assigned to: Nobody/Anonymous (nobody) Summary: Unloading a C++ DLL crashes since GCC 4.5 Initial Comment: Since GCC 4.5, I get crashes on FreeLibrary() freeing a DLL making use of C++ std::string. The problem only happens when invoking the linker by 'gcc' rather than 'g++'. However, both executable and shared library are built by explicitly linking: -lstdc++ The following error message will show to a console or popup box right after the FreeLibrary() call: This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. Very easy to reproduce: DLL code: ------------------------- #include <string> void Test() { std::string("hello"); } -------------------------- gcc -g -Wall -D_DEBUG -c cppTest.cpp -o obj/debug.win32/cppTest.o gcc obj/debug.win32/cppTest.o -shared -lstdc++ -o obj/debug.win32/cppTest.dll (If using g++ instead of gcc here, no problem) Test app code: ------------------------- #include <windows.h> int main() { HMODULE l = LoadLibrary("cppTest"); FreeLibrary(l); return 0; } ------------------------- gcc -g -Wall -D_DEBUG -c cppTestClient.cpp -o obj/debug.win32/cppTestClient.o gcc obj/debug.win32/cppTestClient.o -mwindows -lstdc++ -o obj/debug.win32/cppTestClient.exe Thanks, Jerome ---------------------------------------------------------------------- Comment By: Jerome St-Louis (jerstlouis) Date: 2012-07-10 13:16 Message: Turns out that adding -shared-libgcc to the gcc linker line works fine. (Thanks to apinski on #gcc) Arguably, this should be default when linking with -lstdc++ dynamically. Taking it up with them. Thanks Earnie. ---------------------------------------------------------------------- Comment By: Earnie Boyd (earnie) Date: 2012-07-10 13:02 Message: All I can say is that you're supposed to be using G++ instead of GCC for C++ compilation. If you believe this is truly an issue then take it up with the bugs list for GCC. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=3542140&group_id=2435 |