Repository navigation
🐛 fix(lock): validate holds before reuse - #1098
Merged
Merged
Conversation
An interrupted release can resume after another thread has acquired the lock at the same depth. Check the acquisition generation under the transition gate before retrying. Fixes #1004
A signal handler can acquire a peer after the initial deadlock check. Check the pinned path again before waiting on that peer. Fixes #1083
gaborbernat
marked this pull request as ready for review
November 20, 2026 18:15
gaborbernat
marked this pull request as draft
November 20, 2026 19:32
An errno-bearing signal handler can run after flock released the kernel lock and before filelock clears its descriptor. The instance then treats a later acquire as reentrant and enters without exclusion. Mark the transition uncertain before flock. Require an explicit release retry before the instance can acquire again; a genuine failed syscall keeps its descriptor for that retry. Fixes #999
After a lease reports a lost claim, its descriptor stays open while existing users finish. New calls on the same instance must not join it because a peer may already own the marker. Check reentry before increasing the hold count. Match the compromise token to the current claim so a delayed report for an earlier claim does not reject a new one. Fixes #998
A singleton built from a relative path can be reused for an absolute path. After chdir, acquisition followed the relative spelling and could report a hold on a different file. Reject that acquisition once the shared paths diverge. A new lock constructed after chdir can still use the requested absolute path. Fixes #1018
Threading marks the main thread done before atexit callbacks run. A forced release from another thread could close a hold that the main thread still needs. Keep it until the main thread stops executing. Fixes #1008
gaborbernat
force-pushed
the
reimplement/a2
branch
from
November 20, 2026 19:52
d12c577 to
ee275b9
Compare
gaborbernat
marked this pull request as ready for review
November 20, 2026 21:36
gaborbernat
marked this pull request as draft
November 20, 2026 22:00
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.
A nested acquire could report success after a Unix unlock raised or a lease heartbeat detected a lost claim. Sync and async acquires now raise
RuntimeErrorbefore increasing the depth of either hold. Retry an uncertain Unix unlock withrelease(). Release a lost lease before acquiring it again.A singleton shared through relative and absolute paths raises
RuntimeErrorif a directory change sends its original path to another file. Construct a new lock with the absolute path to acquire the intended file. Reading the current marker's owner still works.During interpreter shutdown, a worker's forced release leaves the main thread's hold available to its exit callbacks.
The November 2026 filelock review reported ANT-2026-IWDBI4I2, ANT-2026-2NN0JREM, ANT-2026-BS2V9OOX, and ANT-2026-5UMFVO63.
Fixes #999, fixes #998, fixes #1018, fixes #1008.