Merge pull request #956 from ermshiperete/bug-xamarin-14987
[mono.git] / mono / metadata / sgen-stw.c
index 12111cbc32dd66949192143a28b0c9935f37abbb..b6fe446cc36d28b5e8d4ca3341b342b5158007a2 100755 (executable)
@@ -200,13 +200,13 @@ sgen_stop_world (int generation)
 {
        int count, dead;
 
-       /*XXX this is the right stop, thought might not be the nicest place to put it*/
-       sgen_process_togglerefs ();
-
        mono_profiler_gc_event (MONO_GC_EVENT_PRE_STOP_WORLD, generation);
        MONO_GC_WORLD_STOP_BEGIN ();
        acquire_gc_locks ();
 
+       /* We start to scan after locks are taking, this ensures we won't be interrupted. */
+       sgen_process_togglerefs ();
+
        update_current_thread_stack (&count);
 
        sgen_global_stop_count++;