Bug 34398 - runtime hook for unhandled exceptions not always called
Summary: runtime hook for unhandled exceptions not always called
Status: NEW
Alias: None
Product: Runtime
Classification: Mono
Component: General (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks: 34385
  Show dependency tree
 
Reported: 2015-09-29 10:48 UTC by Rodrigo Kumpera
Modified: 2015-09-29 11:07 UTC (History)
3 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Rodrigo Kumpera 2015-09-29 10:48:39 UTC
We don't call mono_invoke_unhandled_exception_hook for all unhandled exception.

This is making the iOS team job harder when debugging issues related to it.

We should fix this puppy and add tests for that entrypoint.

Apparently unhandled exceptions in finalizers are ignored if there's an AppDomain.UnhandledException handler.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-09-29 11:07:42 UTC
Just to save what I found out:

There's mono_unhandled_exception [1], which doesn't always exit [2] nor call the hook.

mono_unhandled_exception is called by:
1) ves_icall_System_Runtime_Remoting_Messaging_AsyncResult_Invoke [3], but that function doesn't check if the process should exit (nor does it call the hook)

2)  mono_thread_internal_unhandled_exception [4], which exits (but doesn't call the hook) if Environment.ExitCode is 1 (which the user can change if they wish).

3) mono_handle_exception_internal [5], which also doesn't call neither the hook nor does it ever exit.

[1] https://github.com/mono/mono/blob/d1a87bcac2a8a6fdb669b9789ca608cc89cd9eaa/mono/metadata/object.c#L4091
[2] It's setting Environment.ExitCode to signal that the process should terminate, but the user can also set this in any event handler.
[3] https://github.com/mono/mono/blob/d1a87bcac2a8a6fdb669b9789ca608cc89cd9eaa/mono/metadata/object.c#L6117
[4] https://github.com/mono/mono/blob/d1a87bcac2a8a6fdb669b9789ca608cc89cd9eaa/mono/metadata/threads.c#L4701

Note You need to log in before you can comment on or make changes to this bug.