]> granicus.if.org Git - gc/commitdiff
Fix assertion in GC_malloc_[atomic_]uncollectable (THREADS case only)
authorIvan Maidanski <ivmai@mail.ru>
Wed, 16 May 2012 04:34:10 +0000 (08:34 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 16 May 2012 08:34:33 +0000 (12:34 +0400)
* 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
mallocx.c

index 0fc28fd1c532ae88f4a7babca77b10f3a7558abc..8e5552f8090e5da75c1254e0f8855f139a0f31a0 100644 (file)
--- 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);
index 0d9c0a6ceb8c2d1ce3757f0185acdcb3f3229dcf..b457007c0c48df932d90a05fc7183233e774d60c 100644 (file)
--- 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);