[Git][ghc/ghc][master] rts: fix eager black holes: record mutated closure and fix assertion
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3ba3d9f9 by Luite Stegeman at 2025-11-04T00:59:41-05:00 rts: fix eager black holes: record mutated closure and fix assertion This fixes two problems with handling eager black holes, introduced by a1de535f762bc23d4cf23a5b1853591dda12cdc9. - the closure mutation must be recorded even for eager black holes, since the mutator has mutated it before calling threadPaused - The assertion that an unmarked eager black hole must be owned by the TSO calling threadPaused is incorrect, since multiple threads can race to claim the black hole. fixes #26495 - - - - - 1 changed file: - rts/ThreadPaused.c Changes: ===================================== rts/ThreadPaused.c ===================================== @@ -321,11 +321,12 @@ threadPaused(Capability *cap, StgTSO *tso) if(frame_info == &stg_bh_upd_frame_info) { // eager black hole: we do nothing - // it should be a black hole that we own + // it should be a black hole (but we may not own it, as another + // thread could have raced us to claim it) ASSERT(bh_info == &stg_BLACKHOLE_info || bh_info == &__stg_EAGER_BLACKHOLE_info || bh_info == &stg_CAF_BLACKHOLE_info); - ASSERT(blackHoleOwner(bh) == tso || blackHoleOwner(bh) == NULL); + } else { // lazy black hole @@ -368,13 +369,15 @@ threadPaused(Capability *cap, StgTSO *tso) // The payload of the BLACKHOLE points to the TSO RELEASE_STORE(&((StgInd *)bh)->indirectee, (StgClosure *)tso); SET_INFO_RELEASE(bh,&stg_BLACKHOLE_info); + } - // .. and we need a write barrier, since we just mutated the closure: - recordClosureMutated(cap,bh); + // We need a write barrier, since the closure was mutated (by + // threadPaused for lazy black holes, or the mutator for eager + // black holes). + recordClosureMutated(cap,bh); - // We pretend that bh has just been created. - LDV_RECORD_CREATE(bh); - } + // We pretend that bh has just been created. + LDV_RECORD_CREATE(bh); frame = (StgClosure *) ((StgUpdateFrame *)frame + 1); if (prev_was_update_frame) { View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3ba3d9f9db784c903ebe8fd617447ce6... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3ba3d9f9db784c903ebe8fd617447ce6... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)