Commit 59b5f3b
process_sub: add UUID v4 to FIFO path; fixes test_fifo_path_unique race
The pre-existing FIFO-path generator
/tmp/vsh-fifo-<pid>-<counter>
collided when two ShellState instances shared a pid (e.g., parallel
cargo tests where each test creates a fresh state with the AtomicUsize
counter starting at 0). The first mkfifo wins; the second hits
AlreadyExists and races the first test's cleanup. Surfaced as an
intermittent failure of `process_sub::tests::test_fifo_path_unique`
during this session's batch-7 verification run; passed in isolation.
Fix: append a UUID v4 suffix:
/tmp/vsh-fifo-<pid>-<counter>-<uuidv4>
uuid v1.22 with the v4 feature is already a dep of this crate
(originally for operation IDs in audit logs). The pid + counter
remain useful for grep/debugging discrimination; the UUID makes
collisions cryptographically improbable across:
* two parallel tests in the same binary
* two `vsh` processes that happen to share a recycled pid
* two FIFOs in the same process (counter handles this anyway)
Verified locally:
cargo build -> EXIT 0
Stress loop: 10/10 runs of the process_sub::tests:: suite all pass
(was failing intermittently when called via full
`cargo test` due to parallel scheduling).
Full suite: 703 passed / 0 failed / 14 ignored — unchanged.
This is a real production fix, not just a test fix: the same
`/tmp/vsh-fifo-<pid>-<counter>` collision could affect production
when multiple containerised vsh instances share a pid namespace.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 8fad444 commit 59b5f3b
1 file changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | | - | |
| 51 | + | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
| |||
0 commit comments