#221: a test for more lock waiters than the pool has threads - #222
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
EdmondDantes
force-pushed
the
221-flock-waiter-holds-a-thread
branch
from
August 12, 2026 21:18
ae809d5 to
b4bee78
Compare
Eight coroutines take one lock in turn with UV_THREADPOOL_SIZE=4, each holding it across a suspension point so the waiters really overlap. Against the thread-pool flock the run never finishes; the file ends up with eight lines instead. The lock itself is checked, not only the deadlock: a waiter says so when flock() returns false, and each compares the file size across its own suspension, so a lock granted twice is reported rather than appended over. Removing the flock calls from the body turns the test red — six of eight waiters see another writer. 081 described the locker as blocked in the thread pool, which is no longer where it waits.
EdmondDantes
force-pushed
the
221-flock-waiter-holds-a-thread
branch
from
August 13, 2026 05:21
b4bee78 to
38c78e1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The regression test for #221. The engine side is merged:
true-async/php-src#18 landed on
true-async, andtrue-asyncis merged intotrue-async-stable, so this test now runs against a build that carries the fix.Eight coroutines take one lock in turn with
UV_THREADPOOL_SIZE=4, each holding it acrossa suspension point so that the waiters really overlap. Against the thread-pool
flocktherun never finishes — run-tests kills it on the timeout — because the holder's own write
needs a pool thread and the waiters have taken them all. With the fix the file ends up
with eight lines.
The test belongs here rather than in
ext/standard/tests/file: it needs coroutines, andwhat it pins is the async runtime's promise that waiting for a lock costs no thread.