summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2023-03-07 16:07:38 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-03-25 20:23:48 -0400
commitc32abd4b936b3dfc61974ed5915c330fe7ed10d5 (patch)
treecb23449db519b33c44207dcd0f9aa66a034ad101 /rts
parentc6ec4cd1a94a1b76b7b094d5c92ee605031ecf60 (diff)
downloadhaskell-c32abd4b936b3dfc61974ed5915c330fe7ed10d5.tar.gz
rts: Fix capability-count check in zeroSlop
Previously `zeroSlop` examined `RtsFlags` to determine whether the program was single-threaded. This is wrong; a program may be started with `+RTS -N1` yet the process may later increase the capability count with `setNumCapabilities`. This lead to quite subtle and rare crashes. Fixes #23088.
Diffstat (limited to 'rts')
-rw-r--r--rts/include/rts/storage/ClosureMacros.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/rts/include/rts/storage/ClosureMacros.h b/rts/include/rts/storage/ClosureMacros.h
index e005dc5f78..af4d13a198 100644
--- a/rts/include/rts/storage/ClosureMacros.h
+++ b/rts/include/rts/storage/ClosureMacros.h
@@ -535,9 +535,8 @@ zeroSlop (StgClosure *p,
#endif
;
- const bool can_zero_immutable_slop =
- // Only if we're running single threaded.
- RTS_DEREF(RtsFlags).ParFlags.nCapabilities <= 1;
+ // Only if we're running single threaded.
+ const bool can_zero_immutable_slop = getNumCapabilities() == 1;
const bool zero_slop_immutable =
want_to_zero_immutable_slop && can_zero_immutable_slop;