🐛 fix(unix): suppress EIO on close in Docker bind mounts#513
Merged
gaborbernat merged 1 commit intotox-dev:mainfrom Mar 11, 2026
Merged
🐛 fix(unix): suppress EIO on close in Docker bind mounts#513gaborbernat merged 1 commit intotox-dev:mainfrom
gaborbernat merged 1 commit intotox-dev:mainfrom
Conversation
On macOS Docker with bind-mounted filesystems, the unlink-before-close sequence in _release() causes os.close(fd) to raise EIO. The unlink must stay before unlock to prevent a race where two processes lock different inodes, so we suppress OSError on close instead. At that point the lock is already released and POSIX guarantees the fd is invalidated regardless of the close return value. Fixes tox-dev#512
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.
Since 3.20.4, releasing a
UnixFileLockinside Docker on macOS with bind-mounted filesystems raisesOSError: [Errno 5] Input/output erroronos.close(fd). 🐛 The root cause is theunlink → flock unlock → closesequence in_release(): some FUSE-backed bind-mount drivers returnEIOwhen closing an fd whose directory entry was already removed.The
unlinkmust stay beforeunlockto prevent a race where a concurrent acquirer locks the old inode while a new file is created, so reordering is not an option. Instead,os.close(fd)is now wrapped insuppress(OSError), matching the existing treatment ofunlink. At that point the lock is already released and POSIX guarantees the fd is invalidated regardless of theclosereturn value, so suppressing the error is safe.Fixes #512