GRI-2088: fix ETXTBSY race in pptx_video fake_program test helper #221

Merged
vivy merged 2 commits from fix/GRI-2088-fake-program-etxtbsy into dev 2026-11-15 14:26:03 +00:00
Member

Fixes #220.

pptx_video::tests::fallback_returns_pages_in_page_order failed at random with Failed { tool: "soffice", detail: "Text file busy (os error 26)" }.

Cause: fake_program wrote the fake script with std::fs::write in-process, then exec'd it. A concurrent fork() from another test thread could inherit our open write fd on that file; if our exec landed inside that window, Linux refused it with ETXTBSY (O_CLOEXEC does not close this window — rust-lang/rust#114554).

Fix: fake_program now writes the script via a piped child sh -c 'cat > "$1" && chmod 755 "$1"' instead of writing in-process, so this process never holds a writable fd on the fake program for another fork to inherit. Removed the now-unused PermissionsExt import.

Evidence: ran pptx_video::tests 200 times with --test-threads=16: 0 failures (previously intermittent ETXTBSY).

Local gates (./scripts/local-gates.sh): all green (Rust gates, npm ci, frontend-web check/build).

Fixes #220. `pptx_video::tests::fallback_returns_pages_in_page_order` failed at random with `Failed { tool: "soffice", detail: "Text file busy (os error 26)" }`. **Cause:** `fake_program` wrote the fake script with `std::fs::write` in-process, then exec'd it. A concurrent `fork()` from another test thread could inherit our open write fd on that file; if our `exec` landed inside that window, Linux refused it with `ETXTBSY` (`O_CLOEXEC` does not close this window — rust-lang/rust#114554). **Fix:** `fake_program` now writes the script via a piped child `sh -c 'cat > "$1" && chmod 755 "$1"'` instead of writing in-process, so this process never holds a writable fd on the fake program for another fork to inherit. Removed the now-unused `PermissionsExt` import. **Evidence:** ran `pptx_video::tests` 200 times with `--test-threads=16`: 0 failures (previously intermittent `ETXTBSY`). Local gates (`./scripts/local-gates.sh`): all green (Rust gates, npm ci, frontend-web check/build).
GRI-2088: write fake_program script via child sh instead of in-process fd
Some checks failed
CI / the pre-push hook (pull_request) Successful in 7s
CI / cargo fmt (pull_request) Successful in 7s
CI / cargo deny (pull_request) Successful in 1m10s
CI / cargo clippy (pull_request) Successful in 2m15s
CI / cargo deny advisories (pull_request) Successful in 1m32s
CI / CI (pull_request) Has been cancelled
CI / Notify gate failed (pull_request) Has been cancelled
CI / cargo test (pull_request) Has been cancelled
CI / repository boundary (pull_request) Has been cancelled
CI / frontend-web (pull_request) Successful in 2m40s
9dd501d193
Removes the ETXTBSY race: a concurrent fork() from another test thread
could inherit a writable fd on the fake program before exec, causing
Linux to refuse exec with Text file busy. Writing via 'sh -c cat > ... && chmod'
means this process never holds that fd.
Owner

Reviewed: the fix is right. The writable fd now lives only in a child that has exited before the exec, so no fork can carry it. I merged dev (#219) into the branch so it is current; I merge when CI is green. After that, #217 needs dev merged once more.

Reviewed: the fix is right. The writable fd now lives only in a child that has exited before the exec, so no fork can carry it. I merged dev (#219) into the branch so it is current; I merge when CI is green. After that, #217 needs dev merged once more.
Merge branch 'dev' into fix/GRI-2088-fake-program-etxtbsy
All checks were successful
CI / the pre-push hook (pull_request) Successful in 1m15s
CI / cargo fmt (pull_request) Successful in 1m17s
CI / cargo clippy (pull_request) Successful in 2m12s
CI / cargo deny (pull_request) Successful in 2m45s
CI / cargo deny advisories (pull_request) Successful in 2m8s
CI / frontend-web (pull_request) Successful in 2m37s
CI / repository boundary (pull_request) Successful in 59s
CI / cargo test (pull_request) Successful in 5m30s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 36s
3c4f93288c
vivy merged commit 2d72019113 into dev 2026-11-15 14:26:03 +00:00
vivy deleted branch fix/GRI-2088-fake-program-etxtbsy 2026-11-15 14:26:04 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage!221
No description provided.