Test case to show that unlink(2)+close(2) on OSX still allows open(2) to succeed after link count has dropped to zero.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
Cargo.toml
README.md
gen.py
open-entry-issue
openclosesnoop
sample-log

README.md

Interesting file locking and unlink interactions on OSX.

See the blog post for details.

Build instructions

You will need Rust and cargo. Best to use rustup. Clone this repo, then run

cargo build

This will leave the binary as target/debug/osx-unlink-violation.

The openclosesnoop DTrace script is a modification of Brendan Gregg's opensnoop that ships with OSX. It probes close and unlink in addition to open. Run as:

sudo ./openclosesnoop -a -g -F -n osx-unlink-violation

to start monitoring system calls. If you are on Sierra or higher, you will have to enable DTrace.

The gen.py program generates a set of sample files for the Rust program to act on. A good way to run this to make the problem occur is:

python gen.py 20; ./target/debug/osx-unlink-violation&; ./target/debug/osx-unlink-violation

The problem occurs infrequently. The tell-tale is the !!!... prefixed call to unlink that results in an error, indicating the second process was able to open the file, but not unlink it. The output has the process PID as the first line.