Bug 57736 - Introduce an early profiler shutdown callback
Summary: Introduce an early profiler shutdown callback
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Profiler ()
Version: master
Hardware: All All
: Normal normal
Target Milestone: Future Cycle (TBD)
Assignee: Alex Rønne Petersen
URL:
Depends on:
Blocks:
 
Reported: 2017-06-24 02:43 UTC by Alex Rønne Petersen
Modified: 2017-07-27 14:51 UTC (History)
1 user (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Alex Rønne Petersen 2017-06-24 02:43:35 UTC
Profilers need to be notified just before runtime shutdown begins so they can stop using APIs that depend on the runtime being fully initialized. For example, we've seen this crash in the profiler stress tests a few times:

> 00:56:05 Thread 2 (Thread 0x2af529329700 (LWP 60204)):
> 00:56:05 #0  0x00002af525646ed9 in waitpid () from /lib/x86_64-linux-gnu/libpthread.so.0
> 00:56:05 #1  0x00000000004a9e5e in mono_handle_native_crash (signal=0x6938e9 "SIGSEGV", ctx=<optimized out>, info=<optimized out>) at mini-exceptions.c:2736
> 00:56:05 #2  0x0000000000425f9c in mono_sigsegv_signal_handler (_dummy=11, _info=0x2af529328830, context=0x2af529328700) at mini-runtime.c:3081
> 00:56:05 #3  <signal handler called>
> 00:56:05 #4  0x000000000055cf24 in append_class_name (res=0x2af5380067a0, klass=0x20d0c10, include_namespace=1) at debug-helpers.c:86
> 00:56:05 #5  0x000000000055d628 in mono_type_get_desc (res=res@entry=0x2af5380067a0, type=type@entry=0x20d0cc0, include_namespace=include_namespace@entry=1) at debug-helpers.c:177
> 00:56:05 #6  0x000000000055d806 in mono_type_full_name (type=0x20d0cc0) at debug-helpers.c:235
> 00:56:05 #7  0x000000000055e409 in mono_method_get_name_full (method=0x2af54c018448, signature=signature@entry=1, ret=ret@entry=0, format=format@entry=MONO_TYPE_NAME_FORMAT_IL) at debug-helpers.c:842
> 00:56:05 #8  0x000000000055e779 in mono_method_full_name (method=<optimized out>, signature=signature@entry=1) at debug-helpers.c:925
> 00:56:05 #9  0x00002af52760c6a3 in handle_writer_queue_entry (prof=prof@entry=0x1a11120) at log.c:4257
> 00:56:05 #10 0x00002af52760cad8 in writer_thread (arg=0x1a11120) at log.c:4322
> 00:56:05 #11 0x00002af52563f184 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
> 00:56:05 #12 0x00002af525b68ffd in clone () from /lib/x86_64-linux-gnu/libc.so.6
> 00:56:05 
> 00:56:05 Thread 1 (Thread 0x2af524d2cc40 (LWP 60188)):
> 00:56:05 #0  0x00002af52564065b in pthread_join () from /lib/x86_64-linux-gnu/libpthread.so.0
> 00:56:05 #1  0x00000000006817ee in mono_native_thread_join (tid=<optimized out>) at mono-threads-posix.c:240
> 00:56:05 #2  0x00002af52760e0a3 in log_shutdown (prof=0x1a11120) at log.c:3916
> 00:56:05 #3  0x00000000005b5cc2 in mono_profiler_shutdown () at profiler.c:911
> 00:56:05 #4  0x0000000000422755 in mini_cleanup (domain=0x1a1ba00) at mini-runtime.c:4375
> 00:56:05 #5  0x0000000000477b97 in mono_main (argc=8, argv=<optimized out>) at driver.c:2183
> 00:56:05 #6  0x000000000041fecb in mono_main_with_options (argv=0x7fffe628d5c8, argc=8) at main.c:46
> 00:56:05 #7  main (argc=8, argv=0x7fffe628d5c8) at main.c:339
Comment 1 Alex Rønne Petersen 2017-07-07 00:42:17 UTC
https://github.com/mono/mono/pull/5101
Comment 2 Ludovic Henry 2017-07-07 19:25:20 UTC
Alex, can we mark this bug as resolved since the PR has been merged?
Comment 3 Alex Rønne Petersen 2017-07-08 01:24:12 UTC
Not yet, I still need to actually solve the crash. The profiler API PR was just the foundation needed for that.
Comment 4 Alex Rønne Petersen 2017-07-27 14:51:38 UTC
The crash hasn't shown up in CI for a while, so I'll close this and open a separate bug if it does.