Reputation: 10430
When an exception exits a function in a DLL the mingw32 runtime simply calls terminate std::unexpected instead of propagating the exception to the code that is calling the DLL. What solutions are there to this problem? The DLL and the application calling it are both compiled with the same compiler.
There are two different exception mechanisms supported by mingw32: SJLJ and Dwarf2. Should one of them work better than the other for this? Perhaps the only option is to switch to MSVC or ICC or maybe changing build options alone would help?
Notice that not even catch(...) will catch any exception, not even built-in types (throw 1;), so it is not about the visibility of the exception type.
Upvotes: 12
Views: 1990
Reputation: 59553
Is the runtime assuming that extern "C"
functions will never throw exceptions? I'm not familiar with MinGW but I know that Visual Studio has a bunch of command line arguments to control this sort of behavior. For example, the /EHs
option will cause it to assume that extern "C"
will never throw and it will treat functions that do throw by calling std::unexpected()
which in turn calls std::terminate()
. You might want to call std::set_unexpected()
to establish an unexpected exception handler and see if it traps.
Upvotes: 5
Reputation: 64203
There seams to be a problem with gcc preserving the information about the exception type when the exception is thrown from another shared library.
See this bug report and try googling for "gcc exception shared library" (I still haven't found a solution to that problem)
Upvotes: 0