begin_outside_creation incremented the count of the workers in the scheduling loop with a relaxed operation and then checked whether the pool reached the stopping state. If the increment read the count the last worker left, the check could still see an earlier state, and the thread was created with no worker left to run it. The increment is acq_rel now: each worker saw its state stopping before its decrement (a release), and the decrements form one release sequence, so the check sees the states stopping as well.
Signed-off-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>
A creation of a thread from outside the workers of a pool (#8118) increments the counter of the workers in the scheduling loop and then checks whether the pool has reached the stopping state. The increment was relaxed: if it read the count the last worker left, the check could still see an earlier state, and the thread would be created with no worker left to run it. The increment is an acquire now (acq_rel): each worker saw its state stopping before its decrement, which is a release, and the decrements form one release sequence, so the check sees the states stopping as well.
This was raised in the review of #8118 and again on the V2.0.1 release PR #8099. x86 doesn't reorder here (a read-modify-write is a full barrier), ARM can.