]> granicus.if.org Git - gc/commitdiff
Avoid potential race in print_static_roots called by dyld_image_add/remove
authorIvan Maidanski <ivmai@mail.ru>
Tue, 10 Apr 2018 07:31:57 +0000 (10:31 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 10 Apr 2018 07:31:57 +0000 (10:31 +0300)
* dyn_load.c [DARWIN && DARWIN_DEBUG && !NO_DEBUGGING]
(GC_dyld_image_add, GC_dyld_image_remove): Place LOCK/UNLOCK around
GC_print_static_roots() call.
* dyn_load.c [DARWIN && DARWIN_DEBUG && !NO_DEBUGGING]
(GC_dyld_image_remove): Add DCL_LOCK_STATE.

dyn_load.c

index 7f36b0bb2b65af8b58dcfe131c49ef18b68e756e..190dc107fd6d2660f7ac7d51dbb34359ddc5d631 100644 (file)
@@ -1373,8 +1373,10 @@ STATIC void GC_dyld_image_add(const struct GC_MACH_HEADER *hdr,
     }
   }
 
-# ifdef DARWIN_DEBUG
+# if defined(DARWIN_DEBUG) && !defined(NO_DEBUGGING)
+    LOCK();
     GC_print_static_roots();
+    UNLOCK();
 # endif
 }
 
@@ -1385,6 +1387,9 @@ STATIC void GC_dyld_image_remove(const struct GC_MACH_HEADER *hdr,
   unsigned long start, end;
   unsigned i, j;
   const struct GC_MACH_SECTION *sec;
+# if defined(DARWIN_DEBUG) && !defined(NO_DEBUGGING)
+    DCL_LOCK_STATE;
+# endif
 
   for (i = 0; i < sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]); i++) {
     sec = GC_GETSECTBYNAME(hdr, GC_dyld_sections[i].seg,
@@ -1426,8 +1431,10 @@ STATIC void GC_dyld_image_remove(const struct GC_MACH_HEADER *hdr,
     }
   }
 
-# ifdef DARWIN_DEBUG
+# if defined(DARWIN_DEBUG) && !defined(NO_DEBUGGING)
+    LOCK();
     GC_print_static_roots();
+    UNLOCK();
 # endif
 }