Conversation
posix_lifetime_lock_probe opened a throwaway fd on the lock file to confirm an already-claimed lock, then closed it. fcntl(2) record locks are scoped to (process, inode), so that close silently released the real lock too, even though the reservation's own fd stayed open. Check the in-process claim before opening anything and return early; that branch only ever needed to trust the registry. Signed-off-by: Amir Fathi <amirfathi.me@gmail.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
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.
While chasing #2162 I found a real, separate bug in
posix_lifetime_lock_probe(src/daemon/ipc.c): when the in-process registry says this process already holds the lifetime lock, it still opens a throwaway fd on the lock file just to close it again and return 1.fcntl(2)record locks are scoped to (process, inode), not (fd, inode), so that close silently drops the real lock too, even though the reservation's own fd stays open.Two probes back to back are enough to lose it. I wrote a test that acquires the reservation, probes it twice, then forks a genuinely separate process that tries to take the same lock directly. On main it succeeds, the lock is gone. With the fix it fails as expected.
Fix: check the in-process claim before opening anything and return early. That branch only ever needed to trust the registry, not touch the file.
scripts/test.sh --suites daemon_ipc: the new test fails on main (child_result == 1), 50 passed / 1 skipped with the fix.Not a fix for #2162 itself, I ran into this while reading that code, it's a separate bug.