Skip to content

Commit dd9e11f

Browse files
alexanderkytemarek-safar
authored andcommitted
[crash] Fix async setting for crash reporter
We were previously only setting it from the icall. The icall was therefore fine, while invocations associated with actual dumps caused crashes like this: ``` thread mono#10, name = 'Thread Pool Worker' frame #0: 0x00007fff978dac22 libsystem_kernel.dylib`__psynch_mutexwait + 10 frame #1: 0x00007fff979c5dfa libsystem_pthread.dylib`_pthread_mutex_lock_wait + 100 frame #2: 0x00007fff979c3519 libsystem_pthread.dylib`_pthread_mutex_lock_slow + 285 frame #3: 0x0000000108e0d4a9 mono`mono_loader_lock + 73 frame #4: 0x0000000108dc9106 mono`mono_class_create_from_typedef + 182 frame mono#5: 0x0000000108dc1f2c mono`mono_class_get_checked + 92 frame mono#6: 0x0000000108e21da2 mono`mono_metadata_parse_type_internal + 1378 frame mono#7: 0x0000000108e25e11 mono`mono_metadata_parse_mh_full + 1233 frame mono#8: 0x0000000108ca4f79 mono`mono_debug_add_aot_method + 121 frame mono#9: 0x0000000108cc6b1e mono`decode_exception_debug_info + 5918 frame mono#10: 0x0000000108cc5047 mono`mono_aot_find_jit_info + 1367 frame mono#11: 0x0000000108e082cc mono`mono_jit_info_table_find_internal + 204 frame mono#12: 0x0000000108cdb035 mono`mini_jit_info_table_find_ext + 69 frame mono#13: 0x0000000108cdad5c mono`mono_find_jit_info_ext + 124 frame mono#14: 0x0000000108cdc3a5 mono`unwinder_unwind_frame + 229 frame mono#15: 0x0000000108cdbade mono`mono_walk_stack_full + 798 frame mono#16: 0x0000000108cda1a4 mono`mono_summarize_managed_stack + 100 frame mono#17: 0x0000000108e6dc03 mono`mono_threads_summarize_execute + 1347 frame mono#18: 0x0000000108e6df88 mono`mono_threads_summarize + 360 ```
1 parent 7645c8b commit dd9e11f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

mono/metadata/icall.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5884,11 +5884,7 @@ ves_icall_Mono_Runtime_DumpStateTotal (guint64 *portable_hash, guint64 *unportab
58845884

58855885
mono_get_runtime_callbacks ()->install_state_summarizer ();
58865886

5887-
// if this works
5888-
// - give back loader lock during stop
5889-
mono_thread_info_set_is_async_context (TRUE);
58905887
gboolean success = mono_threads_summarize (ctx, &out, &hashes, TRUE, FALSE, scratch, MONO_MAX_SUMMARY_LEN_ICALL);
5891-
mono_thread_info_set_is_async_context (FALSE);
58925888

58935889
if (!success)
58945890
return mono_string_new_handle (mono_domain_get (), "", error);

mono/metadata/threads.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6355,8 +6355,15 @@ mono_threads_summarize (MonoContext *ctx, gchar **out, MonoStackHash *hashes, gb
63556355
gint64 next_request_id = mono_atomic_load_i64 ((volatile gint64 *) &request_available_to_run);
63566356

63576357
if (next_request_id == this_request_id) {
6358+
gboolean already_async = mono_thread_info_is_async_context ();
6359+
if (!already_async)
6360+
mono_thread_info_set_is_async_context (TRUE);
6361+
63586362
success = mono_threads_summarize_execute (ctx, out, hashes, silent, mem, provided_size);
63596363

6364+
if (!already_async)
6365+
mono_thread_info_set_is_async_context (FALSE);
6366+
63606367
// Only the thread that gets the ticket can unblock future dumpers.
63616368
mono_atomic_inc_i64 ((volatile gint64 *) &request_available_to_run);
63626369
break;

0 commit comments

Comments
 (0)