summaryrefslogtreecommitdiff
path: root/typd_mlc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-06-07 09:06:21 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-06-07 15:07:29 +0300
commitfdd3dc044a171a1d657d0de42547cc5a9d756a30 (patch)
tree667ab55d66712070399e6d6e6ef2822866dba010 /typd_mlc.c
parent1f45c9a9f32b60e3a76e9397e956a47d485f8679 (diff)
downloadbdwgc-fdd3dc044a171a1d657d0de42547cc5a9d756a30.tar.gz
Assert in GC_typed_mark_proc that GC lock is held by some collecting thread
(refactoring) This is to ensure that there is no race in accessing GC_ext_descriptors. * typd_mlc.c (GC_typed_mark_proc): Add comment; add assertion (before accessing GC_ext_descriptors) that either the allocation lock is held (by the current thread) or the parallel marker is on.
Diffstat (limited to 'typd_mlc.c')
-rw-r--r--typd_mlc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/typd_mlc.c b/typd_mlc.c
index 9b7cfbf0..52d35e9e 100644
--- a/typd_mlc.c
+++ b/typd_mlc.c
@@ -310,12 +310,16 @@ STATIC void GC_init_explicit_typing(void)
STATIC mse * GC_typed_mark_proc(word * addr, mse * mark_stack_ptr,
mse * mark_stack_limit, word env)
{
- word bm = GC_ext_descriptors[env].ed_bitmap;
+ word bm;
ptr_t current_p = (ptr_t)addr;
ptr_t greatest_ha = (ptr_t)GC_greatest_plausible_heap_addr;
ptr_t least_ha = (ptr_t)GC_least_plausible_heap_addr;
DECLARE_HDR_CACHE;
+ /* The allocation lock is held by the collection initiating thread. */
+ GC_ASSERT(GC_get_parallel() || I_HOLD_LOCK());
+ bm = GC_ext_descriptors[env].ed_bitmap;
+
INIT_HDR_CACHE;
for (; bm != 0; bm >>= 1, current_p += sizeof(word)) {
if (bm & 1) {