diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2018-03-15 23:16:36 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2018-03-15 23:16:36 +0300 |
commit | d194e44fec13f92baefe66c2e2f14521627a9679 (patch) | |
tree | c041f1b7c26709eee730c1b5cbdd39c69274a419 /dbg_mlc.c | |
parent | cb963c22aa03c2d6f664ef8d7880852559d52ffd (diff) | |
download | bdwgc-d194e44fec13f92baefe66c2e2f14521627a9679.tar.gz |
Add assertions to ensure ADD_CALL_CHAIN is called holding the lock
(code refactoring)
* alloc.c (GC_collect_a_little_inner, GC_allocobj): Add assertion that
the allocation lock is held.
* dbg_mlc.c (GC_store_debug_info_inner): Likewise.
* dbg_mlc.c [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner,
GC_debug_generic_malloc_inner_ignore_off_page): Likewise.
* finalize.c [!GC_TOGGLE_REFS_NOT_NEEDED] (ensure_toggleref_capacity):
Likewise.
* specific.c [USE_CUSTOM_SPECIFIC] (GC_key_create_inner): Likewise.
* alloc.c (GC_allocobj): Remove comment (about the lock).
* dbg_mlc.c [DBG_HDRS_ALL] (GC_debug_generic_malloc_inner): Likewise.
Diffstat (limited to 'dbg_mlc.c')
-rw-r--r-- | dbg_mlc.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -277,6 +277,7 @@ GC_INNER void *GC_store_debug_info_inner(void *p, word sz GC_ATTR_UNUSED, { word * result = (word *)((oh *)p + 1); + GC_ASSERT(I_HOLD_LOCK()); GC_ASSERT(GC_size(p) >= sizeof(oh) + sz); GC_ASSERT(!(SMALL_OBJ(sz) && CROSSES_HBLK((ptr_t)p, sz))); # ifdef KEEP_BACK_PTRS @@ -577,13 +578,13 @@ STATIC void * GC_debug_generic_malloc(size_t lb, int knd, GC_EXTRA_PARAMS) /* An allocation function for internal use. Normally internally */ /* allocated objects do not have debug information. But in this */ /* case, we need to make sure that all objects have debug headers. */ - /* We assume we already hold the GC lock. */ GC_INNER void * GC_debug_generic_malloc_inner(size_t lb, int k) { - void * result = GC_generic_malloc_inner( - SIZET_SAT_ADD(lb, DEBUG_BYTES), k); + void * result; - if (result == 0) { + GC_ASSERT(I_HOLD_LOCK()); + result = GC_generic_malloc_inner(SIZET_SAT_ADD(lb, DEBUG_BYTES), k); + if (NULL == result) { GC_err_printf("GC internal allocation (%lu bytes) returning NULL\n", (unsigned long) lb); return(0); @@ -598,10 +599,12 @@ STATIC void * GC_debug_generic_malloc(size_t lb, int knd, GC_EXTRA_PARAMS) GC_INNER void * GC_debug_generic_malloc_inner_ignore_off_page(size_t lb, int k) { - void * result = GC_generic_malloc_inner_ignore_off_page( - SIZET_SAT_ADD(lb, DEBUG_BYTES), k); + void * result; - if (result == 0) { + GC_ASSERT(I_HOLD_LOCK()); + result = GC_generic_malloc_inner_ignore_off_page( + SIZET_SAT_ADD(lb, DEBUG_BYTES), k); + if (NULL == result) { GC_err_printf("GC internal allocation (%lu bytes) returning NULL\n", (unsigned long) lb); return(0); |