From 9bab7ecc9b7ec5cb8b621f529252b2acfd59d7ff Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 16 May 2012 08:34:10 +0400 Subject: [PATCH] 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. --- malloc.c | 6 +++++- mallocx.c | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/malloc.c b/malloc.c index 2389fd0f..a6b7284f 100644 --- a/malloc.c +++ b/malloc.c @@ -308,7 +308,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 eba43f40..e4902a75 100644 --- a/mallocx.c +++ b/mallocx.c @@ -539,7 +539,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); -- 2.40.0