From: Ivan Maidanski Date: Wed, 16 May 2012 04:34:10 +0000 (+0400) Subject: Fix assertion in GC_malloc_[atomic_]uncollectable (THREADS case only) X-Git-Tag: gc7_4_0~290 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b25be3c7ac53699ca4fddf48c9d724b9575d7f8;p=gc Fix assertion in GC_malloc_[atomic_]uncollectable (THREADS case only) * malloc.c (GC_malloc_uncollectable): Do not check assertion on hb_n_marks to be zero if multi-threaded; add comment. * mallocx.c (GC_malloc_atomic_uncollectable): Likewise. --- diff --git a/malloc.c b/malloc.c index 0fc28fd1..8e5552f8 100644 --- a/malloc.c +++ b/malloc.c @@ -322,7 +322,11 @@ GC_API void * GC_CALL GC_malloc_uncollectable(size_t lb) /* mark bits. */ LOCK(); set_mark_bit_from_hdr(hhdr, 0); /* Only object. */ - GC_ASSERT(hhdr -> hb_n_marks == 0); +# ifndef THREADS + GC_ASSERT(hhdr -> hb_n_marks == 0); + /* This is not guaranteed in the multi-threaded case */ + /* because the counter could be updated before locking. */ +# endif hhdr -> hb_n_marks = 1; UNLOCK(); return((void *) op); diff --git a/mallocx.c b/mallocx.c index 0d9c0a6c..b457007c 100644 --- a/mallocx.c +++ b/mallocx.c @@ -542,7 +542,9 @@ GC_API int GC_CALL GC_posix_memalign(void **memptr, size_t align, size_t lb) LOCK(); set_mark_bit_from_hdr(hhdr, 0); /* Only object. */ - GC_ASSERT(hhdr -> hb_n_marks == 0); +# ifndef THREADS + GC_ASSERT(hhdr -> hb_n_marks == 0); +# endif hhdr -> hb_n_marks = 1; UNLOCK(); return((void *) op);