From c6676b0ff882733f0cbfea92cdf96cf1be6f5858 Mon Sep 17 00:00:00 2001 From: Jonathan Chambers Date: Fri, 25 Aug 2017 03:46:34 -0400 Subject: [PATCH] Retrieve thread lazily and avoid special case for defer. We were trying to get thread when in defer mode even for EVENT_KIND_VM_DEATH and hitting assert since current thread was not available. (#5440) --- mono/mini/debugger-agent.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index e2df12bb6e6..dae5ed21a1c 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -3662,13 +3662,10 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx return; if (agent_config.defer) { - /* Make sure the thread id is always set when doing deferred debugging */ if (is_debugger_thread ()) { /* Don't suspend on events from the debugger thread */ suspend_policy = SUSPEND_POLICY_NONE; - thread = mono_thread_get_main (); } - else thread = mono_thread_current (); } else { if (is_debugger_thread () && event != EVENT_KIND_VM_DEATH) // FIXME: Send these with a NULL thread, don't suspend the current thread @@ -3691,7 +3688,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx thread = NULL; } else { if (!thread) - thread = mono_thread_current (); + thread = is_debugger_thread () ? mono_thread_get_main () : mono_thread_current (); if (event == EVENT_KIND_VM_START && arg != NULL) thread = (MonoThread *)arg; -- 2.25.1