]> granicus.if.org Git - gc/commitdiff
Fix assertion violation in GC_repeat_read if --enable-redirect-malloc
authorIvan Maidanski <ivmai@mail.ru>
Sat, 19 Nov 2016 17:37:04 +0000 (20:37 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Sun, 27 Nov 2016 11:36:34 +0000 (14:36 +0300)
(Cherry-pick commit aed7ec5 from 'release-7_6' branch.)

* malloc.c [REDIRECT_MALLOC && GC_LINUX_THREADS] (GC_init_lib_bounds):
Declare cancel_state local variable; DISABLE_CANCEL for GC_text_mapping
(because GC_repeat_read expects the cancellation state off); call
RESTORE_CANCEL on return.

malloc.c

index c82ce6c9f9ae7aaa39019659984967abb4c8ad30..a5de562784c39df7bd4878ab3066e9f1b8a097a2 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -382,7 +382,10 @@ void * malloc(size_t lb)
 
   STATIC void GC_init_lib_bounds(void)
   {
+    IF_CANCEL(int cancel_state;)
+
     if (GC_libpthread_start != 0) return;
+    DISABLE_CANCEL(cancel_state);
     GC_init(); /* if not called yet */
     if (!GC_text_mapping("libpthread-",
                          &GC_libpthread_start, &GC_libpthread_end)) {
@@ -395,6 +398,7 @@ void * malloc(size_t lb)
     if (!GC_text_mapping("ld-", &GC_libld_start, &GC_libld_end)) {
         WARN("Failed to find ld.so text mapping: Expect crash\n", 0);
     }
+    RESTORE_CANCEL(cancel_state);
   }
 #endif /* GC_LINUX_THREADS */