diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-11-10 12:20:19 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-12-23 19:09:30 -0500 |
commit | 18d2acd2791a751c0b1894fd72dd0317583619cd (patch) | |
tree | 0346e0754521db617ebe684cd5c22f8bc20aa15e /rts/sm | |
parent | 16a1bcd1d72c7a4567671f6a7f610df3fc477519 (diff) | |
download | haskell-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.c | 8 |
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 { |