
Ben Gamari pushed to branch wip/T26053 at Glasgow Haskell Compiler / GHC Commits: 7e7213bd by Ben Gamari at 2025-08-19T10:21:24-04:00 nonmoving: Use get_itbl instead of explicit loads This is cleaner and also fixes unnecessary (and unsound) use of `volatile`. - - - - - a84b4bae by Ben Gamari at 2025-08-19T10:21:24-04:00 rts/Scav: Handle WHITEHOLEs in scavenge_one `scavenge_one`, used to scavenge mutable list entries, may encounter `WHITEHOLE`s when the non-moving GC is in use via two paths: 1. when an MVAR is being marked concurrently 2. when the object belongs to a chain of selectors being short-cutted. Fixes #26204. - - - - - 2 changed files: - rts/sm/NonMovingMark.c - rts/sm/Scav.c Changes: ===================================== rts/sm/NonMovingMark.c ===================================== @@ -619,7 +619,7 @@ inline void updateRemembSetPushThunk(Capability *cap, StgThunk *thunk) { const StgInfoTable *info; do { - info = *(StgInfoTable* volatile*) &thunk->header.info; + info = (StgInfoTable*) RELAXED_LOAD(&thunk->header.info); } while (info == &stg_WHITEHOLE_info); const StgThunkInfoTable *thunk_info = THUNK_INFO_PTR_TO_STRUCT(info); @@ -1343,7 +1343,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) goto done; case WHITEHOLE: - while (*(StgInfoTable* volatile*) &p->header.info == &stg_WHITEHOLE_info) + while (RELAXED_LOAD(&p->header.info) == &stg_WHITEHOLE_info) #if defined(PARALLEL_GC) busy_wait_nop() #endif @@ -1714,7 +1714,7 @@ mark_closure (MarkQueue *queue, const StgClosure *p0, StgClosure **origin) break; case WHITEHOLE: - while (*(StgInfoTable* volatile*) &p->header.info == &stg_WHITEHOLE_info); + while ((StgInfoTable *) RELAXED_LOAD(&p->header.info) == &stg_WHITEHOLE_info); goto try_again; case COMPACT_NFDATA: ===================================== rts/sm/Scav.c ===================================== @@ -1276,6 +1276,7 @@ scavenge_one(StgPtr p) bool no_luck; bool saved_eager_promotion; +try_again: saved_eager_promotion = gct->eager_promotion; ASSERT(LOOKS_LIKE_CLOSURE_PTR(p)); @@ -1617,6 +1618,13 @@ scavenge_one(StgPtr p) scavenge_continuation((StgContinuation *)p); break; + case WHITEHOLE: + // This may happen when the nonmoving GC is in use via two paths: + // 1. when an MVAR is being marked concurrently + // 2. when the object belongs to a chain of selectors being short-cutted. + while (get_itbl((StgClosure*) p) == &stg_WHITEHOLE_info); + goto try_again; + default: barf("scavenge_one: strange object %d", (int)(info->type)); } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d365d9311666f0a0762b38e5640f1e4... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d365d9311666f0a0762b38e5640f1e4... You're receiving this email because of your account on gitlab.haskell.org.