-
Notifications
You must be signed in to change notification settings - Fork 516
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
Marshalled managed exceptions should be considered unhandled exceptions by the debugger #15037
Comments
I wonder if we can just call |
hitting the same issue when executing invalid IL. no exception reported, but a crash logged in Console.app |
Calling However, it seems the app stops too late to show the correct location, the stack has already been unwound a bit (native stacktrace). I believe this is because the debugger and/or runtime doesn't consider that exceptions that happen as a result of calling @thaystg is this something you can give advice about? It seems that doing something like this: static void DoSomething () { throw new Exception ("exception!"); } MonoMethod *doSomethingMethod = ...;
void *arg_ptrs [1];
MonoObject *exception = NULL;
MonoObject *ret;
ret = mono_runtime_invoke (doSomethingMethod, NULL, arg_ptrs, &exception); won't make the debugger in VSCode stop when the exception is thrown. |
Seems like this is a variation of dotnet/android#4927 (comment) |
…ion is marshalled. This means the debugger will be notified of all marshalled exceptions, and consider them unhandled (and break the debugged app into the debugger). There's no corresponding change for CoreCLR, because we have no configuration where we can attach a debugger to a CoreCLR-based app (VSCode doesn't support macOS, and NativeAOT doesn't support debugging). Partial fix for #15037. Fixes dotnet/maui#7176. Ref: dotnet/android#6106
Note: |
@jonpryor I don't think that API will get us (nor you in fact) the behavior we want. We want the debugger to break when the exception is thrown:
That attribute will prevent the debugger from breaking when the exception is thrown, and then we call some API later on to let the debugger know "oh, sorry, please treat this exception as unhandled after all". However, at that point, the stack has already been unwound (somewhat at least), which means the debugging experience is subpar. The documentation for DebuggerDisableUserUnhandledExceptionsAttribute says: "the debugger won't break on user-unhandled exceptions when the exception is caught by a method with this attribute" - we want the opposite of this, something like: "the debugger will break on user-unhandled exceptions even if the exception is caught by a method with this attribute" (or more accurately "the debugger will not consider any exception handlers in this method when determining whether an exception is handled or not") Additionally, we don't have any managed method to attach any attributes or run custom code in, because use the embedding API - |
…ion is marshalled. (#21778) This means the debugger will be notified of all marshalled exceptions, and consider them unhandled (and break the debugged app into the debugger). There's no corresponding change for CoreCLR, because we have no configuration where we can attach a debugger to a CoreCLR-based app (VSCode doesn't support macOS, and NativeAOT doesn't support debugging). Partial fix for #15037. Fixes dotnet/maui#7176. Ref: dotnet/android#6106
The debugger should consider (at least by default) marshalled managed exceptions as unhandled exceptions, and break.
This has become more important with .NET, where we've enabled exception marshalling by default.
A managed exception may now do the following:
Neither are good scenarios, so we should look into what needs to happen to make the debugger break when an exception is marshalled (it's possible runtime changes will be needed).
Ref: dotnet/maui#7176
The text was updated successfully, but these errors were encountered: