From 0cceec20a3d5f665d36dd30551eca460b2fd8ebe Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 19 Nov 2016 20:37:04 +0300 Subject: [PATCH] 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. --- malloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/malloc.c b/malloc.c index 5301518c..a6e0333e 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 */ -- 2.40.0