summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-05-16 06:34:10 +0200
committerIvan Maidanski <ivmai@mail.ru>2012-05-19 15:11:57 +0200
commit9bab7ecc9b7ec5cb8b621f529252b2acfd59d7ff (patch)
treef2cf00644735bd8bde17c4869a93e772f790c8a0
parent7cc205da4c6c561775071626e2e15f6fe99b66f2 (diff)
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.
-rw-r--r--malloc.c6
-rw-r--r--mallocx.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/malloc.c b/malloc.c
index 2389fd0..a6b7284 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 eba43f4..e4902a7 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);