Skip to content

chore: make the fork bomb E2E test deterministic - #90

Merged
koki-develop merged 1 commit into
mainfrom
claude/project-thread-nf5t58
Nov 29, 2026
Merged

koki-develop merged 1 commit into
mainfrom
claude/project-thread-nf5t58

Conversation

@koki-develop

Copy link
Copy Markdown
Member

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 call and exited with 254, while the test expected exit code 0. This is what left main red 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 unavailable and 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 fork hits the pids limit, bash prints fork: retry and sleeps 1, 2, 4 and 8 seconds between retries. The script started sleep 1 children, 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 with Interrupted system call. The script now starts sleep 60 children, 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]
  end
Loading

Reproduced 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

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>
@koki-develop
koki-develop merged commit fde3b0d into main Nov 29, 2026
9 checks passed
@koki-develop
koki-develop deleted the claude/project-thread-nf5t58 branch November 29, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants