We were checking for number of tasks from given pool already active, and then atomically increasing it if allowed - this is not correct, number could be increased by another thread between check and atomic op! Atomic primitives are nice, but you must be very careful with *how* you use them... Now we atomically increase counter, check result, and if we end up over max value, abort and decrease counter again. Spotted by Sergey, thanks!