[debugger] Native thread not executing managed code considered as terminated
authorthaystg <thaystg@users.noreply.github.com>
Thu, 23 Jan 2020 13:32:21 +0000 (13:32 +0000)
committerthaystg <thaystg@users.noreply.github.com>
Thu, 23 Jan 2020 13:32:21 +0000 (13:32 +0000)
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

index e021216..c7c71e6 100644 (file)
@@ -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));