blockifier_test_utils: fix ETXTBSY race in cairo package download#13839
blockifier_test_utils: fix ETXTBSY race in cairo package download#13839avi-starkware wants to merge 1 commit intomain-v0.14.2from
Conversation
`verify_cairo1_package` double-checks `cairo1_package_exists` — once without the lock (fast path) and once after acquiring it. The predicate only tested `.exists()` on the two binaries, so a concurrent process could observe the package as "ready" while `tar` was still mid-write: 1. Process A holds the download lock, `tar` is extracting the archive. 2. `tar` extracts sequentially: first binary is closed, second binary is created (so `.exists()` is true) and being written to. 3. Process B calls `cairo1_package_exists`, sees both files, skips the lock. 4. Process B forks + execs the second binary → Linux returns `ETXTBSY` because the file is still open for writing by `tar`. Fix with the same commit-marker pattern used in `compile_cache.rs`: write `.download_complete` after `tar` finishes, and require it in `cairo1_package_exists`. Until the marker exists, concurrent callers fall through to the lock and wait for the writer. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryLow Risk Overview This writes a Reviewed by Cursor Bugbot for commit 6b91163. Bugbot is set up for automated code reviews on this repo. Configure here. |
dorimedini-starkware
left a comment
There was a problem hiding this comment.
@dorimedini-starkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on avi-starkware).

verify_cairo1_packagedouble-checkscairo1_package_exists— oncewithout the lock (fast path) and once after acquiring it. The predicate
only tested
.exists()on the two binaries, so a concurrent processcould observe the package as "ready" while
tarwas still mid-write:taris extracting the archive.tarextracts sequentially: first binary is closed, second binaryis created (so
.exists()is true) and being written to.cairo1_package_exists, sees both files, skips thelock.
ETXTBSYbecause the file is still open for writing bytar.Fix with the same commit-marker pattern used in
compile_cache.rs:write
.download_completeaftertarfinishes, and require it incairo1_package_exists. Until the marker exists, concurrent callersfall through to the lock and wait for the writer.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com