-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
CLR exceptions in mixed-mode modules #1138
Comments
That is an interesting use-case. Can you provide the set of switches to reproduce this? I want to see what happens inside our SE handlers first. |
Causing any structured exception should be exactly the same and is easier to reproduce than my specific case which involves mixed-mode. This works with the just /EHa switch which allows SEH exceptions to be caught with try/catch.
Catch2 is doing the catch(...) and then uses the nullptr returned from current_exception() in the filtering code, causing a second exception (if I remember correctly). |
I got around experimenting with this and, at least for SEH, |
You are right. I was fooled by how the debugger displays std::exception_ptr. It's good we found another case though! I attached an example project to show CLR exceptions caught in native code, which really do evaluate == nullptr. |
Yep, spent some time there as well. |
Description
In a mixed-mode (native c++ & c++/cli) module native code calls back to the CLR and a CLR exception is thrown. With the right combination of switches this will be caught by
catch(...)
. In this circumstancestd::current_exception
returns nullptr. The translators rethrow the nullptr causing a bad_exception. My fix is shown below. I believe this applies to all Windows structured exceptions but I'm a bit rusty on the details.The text was updated successfully, but these errors were encountered: