From: Ivan Maidanski Date: Sat, 19 Nov 2016 17:37:04 +0000 (+0300) Subject: Fix assertion violation in GC_repeat_read if --enable-redirect-malloc X-Git-Tag: v7.6.2~331 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aed7ec54e287ddbbd13a743927b61368eb617770;p=gc Fix assertion violation in GC_repeat_read if --enable-redirect-malloc * 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. --- diff --git a/malloc.c b/malloc.c index c4a54306..0563cf2b 100644 --- a/malloc.c +++ b/malloc.c @@ -411,7 +411,10 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_uncollectable(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)) { @@ -424,6 +427,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_uncollectable(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 */