Repository navigation
chore: make the fork bomb E2E test deterministic - #90
Merged
Merged
Conversation
The bash fork bomb test started `sleep 1` children. When one of them exited while bash was sleeping between fork retries, the sleep was interrupted and bash sometimes aborted with "fork: Interrupted system call" and exit 254, so the test failed at random on both architectures. Start children that outlive the retries (1+2+4+8 seconds) so bash always retries four times and gives up the same way, and expect that output exactly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before: the E2E test "fork bomb is blocked by cgroup pids limit" (bash) failed at random on both amd64 and arm64. A failing run printed
/sandbox/main.sh: fork: Interrupted system calland exited with 254, while the test expected exit code 0. This is what leftmainred since 2026-09-02, and it also failed PR #87.After: the test gives the same result on every run. Bash retries the fork four times, gives up with
/sandbox/main.sh: fork: Resource temporarily unavailableand exits with 254, and the test expects exactly that output. The test now takes about 15 seconds.The sandbox itself does not change: the cgroup pids limit stopped the fork bomb in every run, passing or failing. Only the test was timing-dependent.
How: when
forkhits the pids limit, bash printsfork: retryand sleeps 1, 2, 4 and 8 seconds between retries. The script startedsleep 1children, so one of them often exited during that sleep. Its SIGCHLD interrupts the sleep, and when that happens with a second or more left, bash stops retrying and aborts withInterrupted system call. The script now startssleep 60children, which outlive all retries, so nothing interrupts them. When bash exits, the PID namespace takes the remaining children with it.flowchart LR subgraph Before["sleep 1 &"] A1[fork fails at pids limit] --> A2[retry, sleep 1s] --> A3[retry, sleep 2s] A3 -- a child exit interrupts the sleep --> A4[Interrupted system call, exit 254] A3 -- children exit between retries --> A5[a later fork succeeds, exit 0] end subgraph After["sleep 60 &"] B1[fork fails at pids limit] --> B2[retry 1s, 2s, 4s, 8s] --> B3[Resource temporarily unavailable, exit 254] endReproduced outside the image with bash 5.2.21 under a cgroup v1 pids limit of 32 and a PID namespace (the image has bash 5.2.15): the old script failed this way in 11 of 40 runs, and the new script gave the same output in 80 of 80 runs.
Generated by Claude Code