summaryrefslogtreecommitdiff
path: root/rts/sm
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-11-10 12:20:19 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-12-23 19:09:30 -0500
commit18d2acd2791a751c0b1894fd72dd0317583619cd (patch)
tree0346e0754521db617ebe684cd5c22f8bc20aa15e /rts/sm
parent16a1bcd1d72c7a4567671f6a7f610df3fc477519 (diff)
downloadhaskell-18d2acd2791a751c0b1894fd72dd0317583619cd.tar.gz
nonmoving: Fix race in marking of blackholes
We must use an acquire-fence when marking to ensure that the indirectee is visible.
Diffstat (limited to 'rts/sm')
-rw-r--r--rts/sm/NonMovingMark.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/rts/sm/NonMovingMark.c b/rts/sm/NonMovingMark.c
index d9758b943f..a42c3c46ce 100644
--- a/rts/sm/NonMovingMark.c
+++ b/rts/sm/NonMovingMark.c
@@ -1510,8 +1510,12 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin)
}
case BLACKHOLE: {
- PUSH_FIELD((StgInd *) p, indirectee);
- StgClosure *indirectee = ((StgInd*)p)->indirectee;
+ // Synchronizes with the release-store in updateWithIndirection.
+ // See Note [Heap memory barriers] in SMP.h.
+ StgInd *ind = (StgInd *) p;
+ ACQUIRE_FENCE();
+ StgClosure *indirectee = RELAXED_LOAD(&ind->indirectee);
+ markQueuePushClosure(queue, indirectee, &ind->indirectee);
if (GET_CLOSURE_TAG(indirectee) == 0 || origin == NULL) {
// do nothing
} else {