diff options
| author | Ben Gamari <ben@smart-cactus.org> | 2023-03-07 16:07:38 -0500 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2023-03-23 13:52:58 -0400 |
| commit | 25422c95aaed438cfaf0cccf02c634ecdd6e73f1 (patch) | |
| tree | e967e32c49ef54b6e657a5684cd2e61dccee8134 | |
| parent | f21cdda2c3c36567e81ef2eaa061fb04a4cbf8b2 (diff) | |
| download | haskell-wip/T23088.tar.gz | |
rts: Fix capability-count check in zeroSlopwip/T23088
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.
| -rw-r--r-- | rts/include/rts/storage/ClosureMacros.h | 5 |
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; |
