`zeroSlop` uses `RtsFlags.ParFlags.nCapabilities` whereas it should be using `n_capabilities`
In #22872 I observed a segmentation fault due to zeroSlop
seemingly incorrectly zeroing slop in a concurrent program (ghc
). This is due to zeroSlop
using the following to determine whether it is running in a single-threaded program:
const bool can_zero_immutable_slop =
// Only if we're running single threaded.
RTS_DEREF(RtsFlags).ParFlags.nCapabilities <= 1;
This is wrong as RtsFlags
only reflects the arguments set at RTS startup, not how many capabilities are currently active (which may have changed due to setNumCapabilities
.
It is remarkable that this went unnoticed for so long.