You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Data race on ctx->threadLimit between POOL_thread() and POOL_create_advanced() #4547
It seems that the ctx->threadLimit variable is updated in POOL_create_advanced() without being protected by the ctx->queueMutex. This can lead to a data race. Will this be a problem?
But to avoid possible RC in the future (if the logic would be not enough anymore) one could indeed rewrite it a bit.
The naive attempt to "fix" it with lock around set of #4558 is in my opinion not correct (even wise versa, can cause a sporadic deadlock).
I'll provide a new PR for that.
Activity
sebres commentedon Mar 1, 2026
There is basically no RC at the moment, since the
ctx(created here) isn't used somewhere else yet, excepting the workers in pool, where the first of them would hold the lock in:https://github.com/facebook/zstd/blob/ae9f20ca2716f2605822ca375995b7d876389b64/lib/common/pool.c#L72
and then enter the conditional wait, because of
ctx->queueEmpty, no matter whatctx->threadLimitis, because by||(or) the value of(ctx->numThreadsBusy >= ctx->threadLimit)is irrelevant:https://github.com/facebook/zstd/blob/ae9f20ca2716f2605822ca375995b7d876389b64/lib/common/pool.c#L74-L75
But to avoid possible RC in the future (if the logic would be not enough anymore) one could indeed rewrite it a bit.
The naive attempt to "fix" it with lock around set of #4558 is in my opinion not correct (even wise versa, can cause a sporadic deadlock).
I'll provide a new PR for that.
avoid potential RC on ctx->threadLimit, code review;
avoid potential RC on ctx->threadLimit, code review;