]> 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>
Sat, 19 May 2012 13:11:57 +0000 (17:11 +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 2389fd0f452e3b52e9b1066840f5b6a22dedc94f..a6b7284f25c18a93f666da7988b380b4ab242808 100644 (file)
--- 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);
index eba43f4056458dc561c6659c08074964baba902a..e4902a7519a28bb86409e87bc67907e4d2365b6a 100644 (file)
--- 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);