summaryrefslogtreecommitdiff
path: root/alloc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-05-13 21:29:28 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-05-19 12:15:03 +0300
commite338ee5fa6057d44308baf69dbb56c118317e493 (patch)
treed6a01d23afc64e7cc547c25c1aebfa0fe3d7062f /alloc.c
parent28ebb9dccd215f8156a5b95335f0bfa021709fd4 (diff)
downloadbdwgc-e338ee5fa6057d44308baf69dbb56c118317e493.tar.gz
Ensure GC_our_memory is updated while holding GC lock
(refactoring) * alloc.c [USE_PROC_FOR_LIBRARIES] (GC_add_to_our_memory): Add assertion that the GC lock is held. * backgraph.c (new_back_edges): Likewise. * misc.c [GC_READ_ENV_FILE] (GC_envfile_init): Likewise. * mark.c [PARALLEL_MARK] (GC_wait_for_markers_init): Add assertion that the GC lock is not hold on entrance; wrap GC_add_to_our_memory() call into LOCK/UNLOCK. * mark.c [PARALLEL_MARK] (GC_do_parallel_mark): Move assertion about the GC lock to be the first statement. * misc.c [GC_ASSERTIONS && GC_ALWAYS_MULTITHREADED] (GC_init): Move the first call of LOCK() upper to be before GC_envfile_init(). * misc.c [LINT2] (GC_init): Set GC_dont_gc directly (instead of GC_disable() call) if GC_ASSERTIONS and GC_ALWAYS_MULTITHREADED.
Diffstat (limited to 'alloc.c')
-rw-r--r--alloc.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/alloc.c b/alloc.c
index 242cb741..a1fb9ad2 100644
--- a/alloc.c
+++ b/alloc.c
@@ -1315,6 +1315,7 @@ GC_API void GC_CALL GC_gcollect_and_unmap(void)
/* Add HBLKSIZE aligned, GET_MEM-generated block to GC_our_memory. */
GC_INNER void GC_add_to_our_memory(ptr_t p, size_t bytes)
{
+ GC_ASSERT(I_HOLD_LOCK());
GC_ASSERT(p != NULL);
if (GC_n_memory >= MAX_HEAP_SECTS)
ABORT("Too many GC-allocated memory sections: Increase MAX_HEAP_SECTS");