Skip to content

🐛 fix(soft): restore markers after interrupted exchange - #1080

Merged
gaborbernat merged 5 commits into
mainfrom
fix/soft-exchange-interrupt-993
Nov 20, 2026
Merged

gaborbernat merged 5 commits into
mainfrom
fix/soft-exchange-interrupt-993

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

On Linux and macOS filesystems that support atomic name exchange, a signal could interrupt SoftFileLock after a marker moved aside but before the exchange returned. An interrupted takeover could then admit a second holder. Cleanup after a failed acquire could also leave an empty file that blocked later callers. Fixes #993.

Python signal handlers can raise before an exchange reports success. An interrupted takeover restores the displaced marker. During removal, cleanup checks the displaced file's inode and modification time. Cleanup removes the original marker, including an empty one left by a failed acquire, when both values match. If a peer replaced the marker, cleanup puts the replacement back.

Reported by OSS Scanner (ANT-2026-3HY24V2J).

A signal can run after the kernel swaps lock names but before Python records
the result. Cleanup then removes the marker at the lock path while a live
holder's marker remains under a break name.

Arm rollback before the exchange call. Cleanup sees the contender's marker
under its break name if no swap occurred, and returns a displaced holder's
marker when the swap completed.

Fixes #993
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 15:32
@gaborbernat gaborbernat changed the title 🐛 fix(soft): restore holder after interrupted exchange 🐛 fix(soft): restore markers after interrupted exchange Nov 20, 2026
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 17:33
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 19:32
A failed acquire can leave an empty marker if a signal interrupts its removal.
Check which file the exchange moved aside before deciding whether to restore it.
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 21:28
@gaborbernat
gaborbernat merged commit 3b1f500 into main Nov 20, 2026
49 checks passed
@gaborbernat
gaborbernat deleted the fix/soft-exchange-interrupt-993 branch November 20, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interrupted stale takeover can admit concurrent soft lock holders

1 participant