diff options
author | Alexander Kyte <alkyte@microsoft.com> | 2018-10-30 20:05:29 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2018-10-31 10:31:16 +0300 |
commit | b2915194221220c531c78e3cde339db38d488378 (patch) | |
tree | 2ed3ba38494530b4b68930dfee9bc82e58ddcc93 | |
parent | 149206a5eed02784f04e1c4d8e470f0d8eedc767 (diff) |
[crash] Fix async setting for crash reportermono-5.16.0.208
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 #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 #5: 0x0000000108dc1f2c mono`mono_class_get_checked + 92
frame #6: 0x0000000108e21da2 mono`mono_metadata_parse_type_internal + 1378
frame #7: 0x0000000108e25e11 mono`mono_metadata_parse_mh_full + 1233
frame #8: 0x0000000108ca4f79 mono`mono_debug_add_aot_method + 121
frame #9: 0x0000000108cc6b1e mono`decode_exception_debug_info + 5918
frame #10: 0x0000000108cc5047 mono`mono_aot_find_jit_info + 1367
frame #11: 0x0000000108e082cc mono`mono_jit_info_table_find_internal + 204
frame #12: 0x0000000108cdb035 mono`mini_jit_info_table_find_ext + 69
frame #13: 0x0000000108cdad5c mono`mono_find_jit_info_ext + 124
frame #14: 0x0000000108cdc3a5 mono`unwinder_unwind_frame + 229
frame #15: 0x0000000108cdbade mono`mono_walk_stack_full + 798
frame #16: 0x0000000108cda1a4 mono`mono_summarize_managed_stack + 100
frame #17: 0x0000000108e6dc03 mono`mono_threads_summarize_execute + 1347
frame #18: 0x0000000108e6df88 mono`mono_threads_summarize + 360
```
-rw-r--r-- | mono/metadata/icall.c | 2 | ||||
-rw-r--r-- | mono/metadata/threads.c | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index 624e550f1ce..72ddd5124d0 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -5983,9 +5983,7 @@ ves_icall_Mono_Runtime_DumpStateTotal (guint64 *portable_hash, guint64 *unportab mono_get_runtime_callbacks ()->install_state_summarizer (); - mono_thread_info_set_is_async_context (TRUE); gboolean success = mono_threads_summarize (ctx, &out, &hashes, TRUE, FALSE, scratch, MONO_MAX_SUMMARY_LEN_ICALL); - mono_thread_info_set_is_async_context (FALSE); if (!success) return mono_string_new_handle (mono_domain_get (), "", error); diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index 69acdec9e9e..384ed9e8362 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -6214,8 +6214,15 @@ mono_threads_summarize (MonoContext *ctx, gchar **out, MonoStackHash *hashes, gb gint64 next_request_id = mono_atomic_load_i64 ((volatile gint64 *) &request_available_to_run); if (next_request_id == this_request_id) { + gboolean already_async = mono_thread_info_is_async_context (); + if (!already_async) + mono_thread_info_set_is_async_context (TRUE); + success = mono_threads_summarize_execute (ctx, out, hashes, silent, mem, provided_size); + if (!already_async) + mono_thread_info_set_is_async_context (FALSE); + // Only the thread that gets the ticket can unblock future dumpers. mono_atomic_inc_i64 ((volatile gint64 *) &request_available_to_run); break; |