Commit 6de9b6eb authored by Simon Marlow's avatar Simon Marlow Committed by Austin Seipp
Browse files

Fix for crash in setnumcapabilities001

getNewNursery() was unconditionally incrementing next_nursery, which
is normally fine but it broke an assumption in
storageAddCapabilities().  This manifested as an occasional crash in
the setnumcapabilities001 test.

(cherry picked from commit be0ce871)
parent 0d939ca1
......@@ -549,6 +549,7 @@ allocNursery (bdescr *tail, W_ blocks)
assignNurseryToCapability (Capability *cap, nat n)
ASSERT(n < n_nurseries);
cap->r.rNursery = &nurseries[n];
cap->r.rCurrentNursery = nurseries[n].blocks;
......@@ -699,14 +700,19 @@ resizeNurseries (W_ blocks)
getNewNursery (Capability *cap)
StgWord i = atomic_inc(&next_nursery, 1) - 1;
if (i >= n_nurseries) {
return rtsFalse;
StgWord i;
for(;;) {
i = next_nursery;
if (i >= n_nurseries) {
return rtsFalse;
if (cas(&next_nursery, i, i+1) == i) {
assignNurseryToCapability(cap, i);
return rtsTrue;
assignNurseryToCapability(cap, i);
return rtsTrue;
/* -----------------------------------------------------------------------------
move_STACK is called to update the TSO structure after it has been
moved from one place to another.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment