From 009d5e9ab2e42fc564ff53f5c519d47969a3d2af Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksey=20Kliger=20=28=CE=BBgeek=29?= Date: Sat, 5 Oct 2019 13:01:56 -0400 Subject: [PATCH] [merp] Put thread into async context before running summarizer (mono/mono#17194) Followup work for https://github.com/mono/mono/pull/17090 In order to get managed method info for unmanaged stacktraces, we call mini_jit_info_table_find_ext which calls decode_exception_debug_info which may allocate if it's not in async context. Do the switch in mono_threads_summarize_execute so that non-supervising threads all switch when they run the sigterm_signal_handler. mono_threads_summarize already does it for the supervisor thread. Fixes https://github.com/mono/mono/issues/17180 Commit migrated from https://github.com/mono/mono/commit/cb52186661254bb17e809ccb753198e7e59c2d90 --- src/mono/mono/metadata/threads.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/threads.c b/src/mono/mono/metadata/threads.c index b008e5f..b55283a 100644 --- a/src/mono/mono/metadata/threads.c +++ b/src/mono/mono/metadata/threads.c @@ -6597,7 +6597,14 @@ mono_threads_summarize_init (void) gboolean mono_threads_summarize_execute (MonoContext *ctx, gchar **out, MonoStackHash *hashes, gboolean silent, gchar *working_mem, size_t provided_size) { - return mono_threads_summarize_execute_internal (ctx, out, hashes, silent, working_mem, provided_size, FALSE); + gboolean result; + gboolean already_async = mono_thread_info_is_async_context (); + if (!already_async) + mono_thread_info_set_is_async_context (TRUE); + result = mono_threads_summarize_execute_internal (ctx, out, hashes, silent, working_mem, provided_size, FALSE); + if (!already_async) + mono_thread_info_set_is_async_context (FALSE); + return result; } gboolean -- 2.7.4