[sgen] Fix verify-before-allocs.
authorJon Purdy <evincarofautumn@gmail.com>
Thu, 13 Oct 2016 21:06:25 +0000 (14:06 -0700)
committerJon Purdy <evincarofautumn@gmail.com>
Thu, 13 Oct 2016 21:06:25 +0000 (14:06 -0700)
sgen_check_whole_heap_stw() calls sgen_stop_world(), which assumes the
GC lock is held.

mono/sgen/sgen-alloc.c

index d18fc7cfc73462dcbc69a84a794258fcf196a106..fa6046f519a7eca2a9bb6b91854e07ac7058da5c 100644 (file)
@@ -402,8 +402,11 @@ sgen_alloc_obj (GCVTable vtable, size_t size)
                int current_alloc = InterlockedIncrement (&alloc_count);
 
                if (verify_before_allocs) {
-                       if ((current_alloc % verify_before_allocs) == 0)
+                       if ((current_alloc % verify_before_allocs) == 0) {
+                               LOCK_GC;
                                sgen_check_whole_heap_stw ();
+                               UNLOCK_GC;
+                       }
                }
                if (collect_before_allocs) {
                        if (((current_alloc % collect_before_allocs) == 0) && nursery_section) {