diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-06-07 09:06:21 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-06-07 15:07:29 +0300 |
commit | fdd3dc044a171a1d657d0de42547cc5a9d756a30 (patch) | |
tree | 667ab55d66712070399e6d6e6ef2822866dba010 /typd_mlc.c | |
parent | 1f45c9a9f32b60e3a76e9397e956a47d485f8679 (diff) | |
download | bdwgc-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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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) { |