[sgen] Don't assert when suspending detaching thread (#4292)
authorVlad Brezae <brezaevlad@gmail.com>
Mon, 6 Feb 2017 19:20:21 +0000 (21:20 +0200)
committerLudovic Henry <ludovic@xamarin.com>
Mon, 6 Feb 2017 19:20:21 +0000 (14:20 -0500)
This means that the thread will be part of the stw (not skipped), so if the stack pointer is not between the expected ranges we dont scan the thread. In other parts of the runtime, suspending here is handled by the suspend_can_continue flag.

mono/metadata/sgen-stw.c
mono/mini/mini-exceptions.c

index 22ff814df699bdcad3b99b174a2f25ee433e93ea..88f25d67c67c87b8a9d06175f90c606a3057b8a2 100644 (file)
@@ -358,12 +358,14 @@ sgen_unified_suspend_stop_world (void)
                /* Once we remove the old suspend code, we should move sgen to directly access the state in MonoThread */
                info->client_info.stack_start = (gpointer) ((char*)MONO_CONTEXT_GET_SP (&info->client_info.ctx) - REDZONE_SIZE);
 
-               /* altstack signal handler, sgen can't handle them, mono-threads should have handled this. */
-               if (!info->client_info.stack_start
-                        || info->client_info.stack_start < info->client_info.stack_start_limit
+               if (info->client_info.stack_start < info->client_info.stack_start_limit
                         || info->client_info.stack_start >= info->client_info.stack_end) {
-                       g_error ("BAD STACK: stack_start = %p, stack_start_limit = %p, stack_end = %p",
-                               info->client_info.stack_start, info->client_info.stack_start_limit, info->client_info.stack_end);
+                       /*
+                        * Thread context is in unhandled state, most likely because it is
+                        * dying. We don't scan it.
+                        * FIXME We should probably rework and check the valid flag instead.
+                        */
+                       info->client_info.stack_start = NULL;
                }
 
                stopped_ip = (gpointer) (MONO_CONTEXT_GET_IP (&info->client_info.ctx));
index f3b918e565ea10d74a8489fa82af2facbe2c6166..c390ee9ea6cae9ccd31f5ebf2f3a2e1e5075838b 100644 (file)
@@ -2871,7 +2871,6 @@ mono_thread_state_init_from_sigctx (MonoThreadUnwindState *ctx, void *sigctx)
        MonoThreadInfo *thread = mono_thread_info_current_unchecked ();
        if (!thread) {
                ctx->valid = FALSE;
-               g_error ("Invoked mono_thread_state_init_from_sigctx from non-Mono thread");
                return FALSE;
        }