From 16067e0a861ef4b72b931db3f0253c807e40fb6b Mon Sep 17 00:00:00 2001 From: thaystg Date: Thu, 23 Jan 2020 13:32:21 +0000 Subject: [PATCH] [debugger] Native thread not executing managed code considered as terminated If a thread was suspended and doesn't have any managed stack, it was considered as terminated, but it wasn't really terminated because it can execute managed code again, and stop in a breakpoint so if the execution arrives in debugger_agent_breakpoint_from_context we reset the flag terminated to FALSE. Fixes #18106 --- src/mono/mono/mini/debugger-agent.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mono/mono/mini/debugger-agent.c b/src/mono/mono/mini/debugger-agent.c index e021216..c7c71e6 100644 --- a/src/mono/mono/mini/debugger-agent.c +++ b/src/mono/mono/mini/debugger-agent.c @@ -4898,6 +4898,8 @@ debugger_agent_single_step_from_context (MonoContext *ctx) g_assert (tls); + tls->terminated = FALSE; + /* Have to save/restore the restore_ctx as we can be called recursively during invokes etc. */ memcpy (&orig_restore_state, &tls->restore_state, sizeof (MonoThreadUnwindState)); mono_thread_state_init_from_monoctx (&tls->restore_state, ctx); @@ -4924,6 +4926,11 @@ debugger_agent_breakpoint_from_context (MonoContext *ctx) tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id); g_assert (tls); + + //if a thread was suspended and doesn't have any managed stack, it was considered as terminated, + //but it wasn't really terminated because it can execute managed code again, and stop in a breakpoint so here we set terminated as FALSE + tls->terminated = FALSE; + memcpy (&orig_restore_state, &tls->restore_state, sizeof (MonoThreadUnwindState)); mono_thread_state_init_from_monoctx (&tls->restore_state, ctx); memcpy (&tls->handler_ctx, ctx, sizeof (MonoContext)); -- 2.7.4