🐛 fix(soft_rw): evict non-regular write marker without reading it#588
Merged
gaborbernat merged 1 commit intoJul 7, 2026
Merged
Conversation
afc5d05 to
358cb26
Compare
_read_marker read the marker to judge it, but reading a FIFO diverges by platform: an empty non-blocking read yields 0 bytes on Linux/macOS (so the FIFO parses as a malformed marker and gets evicted) but raises EAGAIN on FreeBSD, where _read_marker then returned None, _break_stale_marker bailed, and the stale FIFO wedged the acquire until timeout (tox-dev#587). A legitimate marker is always a regular file, so fstat the fd and report anything else as a malformed marker straight away -- its mtime still drives stale eviction -- instead of reading it. fstat classifies the FIFO the same on every platform, so the writerless case FreeBSD tripped on and the writer-attached case that raises EAGAIN everywhere both evict. Add test_fifo_write_marker_with_writer_is_evicted: attaching a writer forces the EAGAIN path on any platform, reproducing the FreeBSD failure portably. It times out at the same _wait_for line before the fix.
358cb26 to
7f2318a
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.
Acquiring a
SoftReadWriteLockhangs until it times out on FreeBSD when a stale FIFO sits at the.writemarker path._read_markeropens the marker withO_NONBLOCKand reads it to decide whether it is valid, but a non-blocking read of a FIFO returns zero bytes on Linux and macOS while it raisesEAGAINon FreeBSD. 🐛 On theEAGAINpath_read_markerreturnsNone, so_break_stale_markertreats the marker as already gone, leaves it in place, and the writer-slot claim spins untilTimeout.A legitimate marker is a regular file, created with
O_CREAT | O_EXCL | O_WRONLY, so the fix checks the file type withfstatand reports anything else as a malformed marker without reading it, letting itsmtimedrive stale eviction instead of content whose read behavior varies by platform.fstatclassifies the FIFO by its inode type rather than by a platform-specific read, so both the writerless marker FreeBSD tripped on and a writer-attached marker that raisesEAGAINget evicted.Linux and macOS keep their current behavior, since a stale FIFO already resolved to a malformed marker on those platforms. Fixes #587.