Skip to content

fix(test): confine the RLIMIT_FSIZE atomic-write repro to a child process - #227

Merged
Mikola Lysenko (mikolalysenko) merged 1 commit into
mainfrom
fix/fsize-rlimit-test-isolation
Aug 21, 2026
Merged

fix(test): confine the RLIMIT_FSIZE atomic-write repro to a child process#227
Mikola Lysenko (mikolalysenko) merged 1 commit into
mainfrom
fix/fsize-rlimit-test-isolation

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

What

cargo test --workspace intermittently (on this machine: reliably) exits 101 with zero failed tests: utils/fs.rs's atomic_write_failed_stage_write_errors_and_keeps_target (added in #223) caps RLIMIT_FSIZE to 256 KiB and ignores SIGXFSZ process-wide during its window. #[serial] only serializes against other #[serial] tests — every concurrently-running sibling test, and the libtest harness itself (io error when listing tests: … FileTooLarge), that wrote >256 KiB during the window died with EFBIG and aborted the whole core-lib binary mid-run.

Why not just resize

The payload must stay within tokio's single 2 MiB write chunk: the bug this test pins is write_all buffering the whole payload and returning Ok before the background write hits EFBIG, with sync_all storing the error instead of returning it. A multi-chunk payload surfaces the error directly and stops exercising the swallowed-error path — so the cap can't be raised out of siblings' reach.

How

The parent arm re-execs the test binary filtered (--exact) to this one test with a marker env var selecting the capped body — the rlimit's blast radius is now a single-test child process. An anti-vacuity assert on the child's 1 passed summary keeps a future rename from turning the child run into a filter-matches-nothing no-op.

Validation

  • RED-guard cycle: reintroducing the guarded bug (removing flush()) fails the confined test; restoring it passes.
  • cargo test --workspace: 0/3 green before the fix → 2/2 green after on the machine that reproduced it; -p socket-patch-core --lib 2526/2526.
  • Found while gating feat(get): --mode hosted|vendored with installed-version narrowing of advisory fan-outs #226 (which is unaffected — it touches no core file); root-cause narrative also in that PR's description.

🤖 Generated with Claude Code


Note

Low Risk
Test-only isolation of an existing Unix regression; production atomic-write code is unchanged.

Overview
Stops cargo test --workspace from aborting with exit 101 and zero failed tests when the Unix atomic-write EFBIG regression test is running.

atomic_write_failed_stage_write_errors_and_keeps_target still caps RLIMIT_FSIZE (and ignores SIGXFSZ) to pin the swallowed-sync_all path, but that cap is now applied only in a re-exec’d child filtered to this one test. #[serial] is dropped because it never protected concurrent non-serial siblings or the harness. The parent asserts child success and that stdout contains 1 passed so a rename cannot make the filter a no-op.

Reviewed by Cursor Bugbot for commit 183eaed. Configure here.

…cess

atomic_write_failed_stage_write_errors_and_keeps_target (from #223) capped
RLIMIT_FSIZE to 256 KiB and ignored SIGXFSZ PROCESS-WIDE for its window.
#[serial] only serializes against other #[serial] tests, so every
concurrently-running sibling test — and the libtest harness itself — that
wrote a file larger than the cap died with EFBIG, aborting the whole core
lib binary: observed as `cargo test --workspace` exiting 101 with ZERO
failed tests and `io error when listing tests: … FileTooLarge`
(reproduced 3/3 on this machine; the binary passes solo).

The sizes cannot simply be raised out of siblings' range: the payload must
fit tokio's single 2 MiB write chunk or write_all surfaces the error
directly and the swallowed-sync_all path the test pins is never exercised.
Instead the parent re-execs the test binary filtered (--exact) to this one
test with a marker env var selecting the capped body, confining the blast
radius to a single-test child process. An anti-vacuity assert on the
child's "1 passed" summary keeps a future rename from silently turning
the child run into a filter-matches-nothing no-op.

Validated: the test still goes RED when the guarded bug is reintroduced
(flush() removed → child fails → parent fails); cargo test --workspace
0/3 green before the fix, 2/2 green after; core lib 2526/2526.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) merged commit 235299a into main Aug 21, 2026
63 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the fix/fsize-rlimit-test-isolation branch August 21, 2026 01:35
Mikola Lysenko (mikolalysenko) added a commit that referenced this pull request Aug 21, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants