clean-install proof: a child a start forked can escape killEvenIfGone's walk (orphaned, no refusal), about 1 in 480 runs under load #356

Closed
opened 2026-12-01 10:22:51 +00:00 by saturnus · 3 comments
Member

Purpose (fix): the clean-install proof's teardown kills everything a start began, so nothing a member forked outlives it, even for a moment.

Found while reproducing #340 (Done-when 1), on msi00 in the installer job's image (node:24-trixie@sha256:6e5d4c38, the runner user with sudo, tini -s, git 2.56.1), 4 containers at once. The case was "a start in flight is killed with everything under it" from installer/prove_a_clean_install/prove_a_clean_install.node-test.mjs.

What was seen. A diagnostic listed the start's session (ps -s) right after killEvenIfGone returned and the writer was confirmed gone.

  • In 4 of 480 runs, one sleep 0.05 was still in the session, in state S: never stopped, so never one of the processes the walk froze.
  • In 1 of 480 runs (a second round), the survivor was sleep 0.05 (pid 4102, newer than the writer's pid 4084). Its parent was by then the container's subreaper (tini -s): it had been orphaned. killEvenIfGone returned no refusals.
  • Before the #340 fix, 2 runs in 240 failed the file on martha-clean-install-test-*/relay/wrote, recreated after the tree was removed, with every case green. That is what this escape looks like when the escaping child is the writer's mkdir -p or date >.

The #340 fix stops it from leaving anything behind in that case: the tree is removed only once the session is empty. The escape itself is in frozenUnder/killEvenIfGone (prove_a_clean_install.mjs), and the proof's own tearDown can meet it too: a member's child that escapes the walk could write under the relay root after the teardown removed it (the martha#590 note).

Not yet known. How a child the writer forked escapes a walk that stops each process before it reads its children (martha#590 r=1), with no refusal. A child forked while the stop was being taken? A pgrep read that missed a brand-new pid?

Done when:

  • the escape is named from a reproduction (the in-flight case, many runs under load, with the session listed after the kill), and
  • killEvenIfGone leaves nothing in the start's session, or names what is left as a refusal, and the case asserts that across the same number of runs.

Refs #340, martha#590, martha#628

Purpose (fix): the clean-install proof's teardown kills everything a start began, so nothing a member forked outlives it, even for a moment. Found while reproducing #340 (Done-when 1), on msi00 in the installer job's image (node:24-trixie@sha256:6e5d4c38, the runner user with sudo, tini -s, git 2.56.1), 4 containers at once. The case was "a start in flight is killed with everything under it" from `installer/prove_a_clean_install/prove_a_clean_install.node-test.mjs`. **What was seen.** A diagnostic listed the start's session (`ps -s`) right after `killEvenIfGone` returned and the writer was confirmed gone. - In 4 of 480 runs, one `sleep 0.05` was still in the session, in state S: never stopped, so never one of the processes the walk froze. - In 1 of 480 runs (a second round), the survivor was `sleep 0.05` (pid 4102, newer than the writer's pid 4084). Its parent was by then the container's subreaper (`tini -s`): it had been orphaned. `killEvenIfGone` returned no refusals. - Before the #340 fix, 2 runs in 240 failed the file on `martha-clean-install-test-*/relay/wrote`, recreated after the tree was removed, with every case green. That is what this escape looks like when the escaping child is the writer's `mkdir -p` or `date >`. The #340 fix stops it from leaving anything behind in that case: the tree is removed only once the session is empty. The escape itself is in `frozenUnder`/`killEvenIfGone` (prove_a_clean_install.mjs), and the proof's own tearDown can meet it too: a member's child that escapes the walk could write under the relay root after the teardown removed it (the martha#590 note). **Not yet known.** How a child the writer forked escapes a walk that stops each process before it reads its children (martha#590 r=1), with no refusal. A child forked while the stop was being taken? A pgrep read that missed a brand-new pid? Done when: - the escape is named from a reproduction (the in-flight case, many runs under load, with the session listed after the kill), and - `killEvenIfGone` leaves nothing in the start's session, or names what is left as a refusal, and the case asserts that across the same number of runs. Refs #340, martha#590, martha#628
Author
Member

The same class in a second case. The installer job's image on msi00, 3 containers at once, the whole prove_a_clean_install.node-test.mjs:

  • a run that forks while it is walked is frozen, so nothing of it outlives the tear-down (martha#590 r=1) failed nothing in the run's session <n> is alive after the tear-down, 1 run in 24.
  • That happened on main 60ce2063, and again on the martha#340 tip f8b7e65d, whose change to this case is only how it reads the run's pid.
  • Every other case was green in all 48 runs.
  • This case already asserts the whole session empty after killEvenIfGone, so the escape shows here as a named red rather than a leftover tree.
**The same class in a second case.** The installer job's image on msi00, 3 containers at once, the whole `prove_a_clean_install.node-test.mjs`: - `a run that forks while it is walked is frozen, so nothing of it outlives the tear-down (martha#590 r=1)` failed `nothing in the run's session <n> is alive after the tear-down`, 1 run in 24. - That happened on main 60ce2063, and again on the martha#340 tip f8b7e65d, whose change to this case is only how it reads the run's pid. - Every other case was green in all 48 runs. - This case already asserts the whole session empty after `killEvenIfGone`, so the escape shows here as a named red rather than a leftover tree.
Author
Member

Cause, threat model and Done-when (Saturnus, 2026-12-01; package placed by Mars).

Reproduction: msi00, the installer job's image (node:24-trixie@sha256:6e5d4c38, the node user under tini -s), 4 containers at once at nice -n 10.

  • A standalone script starts a writer through startOnATerminal, shaped as the in-flight case: mkdir -p / date > / sleep 0.05, trap '' HUP, and the test file's lifeline watcher.
  • It calls killEvenIfGone, then lists the start's session (ps -s).
  • The processes seam is wrapped to timestamp every identity and stop check on the /proc uptime clock.

Cause, named. killEvenIfGone freezes the tree top-down, which is right. Then it kills in the same order: the wrapper (script) first, the run deepest last. Ending the wrapper resumes the stopped processes under it.

  • A run already confirmed stopped (stop <writer> stopped) gets a SIGCONT before its own SIGKILL reaches it.
  • In that window it forks again. That child was never walked, so it is orphaned to the subreaper and outlives the tear-down, with no refusal.
  • A timestamped sample: the writer was confirmed stopped at 822223.28, the walk ended and the kills began at 822223.35, and the survivor sleep 0.05 was born at 822223.35.
kill order (frozen) runs child escaped the run was given a SIGCONT
as on main, wrapper first (timed walk) 1600 11 not measured
as on main, wrapper first (a CONT trap in the writer) 1600 1 31
deepest first (the same list, reversed) 1600 0 0

(The CONT trap slows the writer, so fewer of its resumes reach a fork. The one escape in that round logged no CONT, because dash runs a trap only between commands, and the writer was killed before it ran the trap.)

Threat model. This is the proof's own tear-down, which signals real processes.

  1. It must never signal what it did not start (martha#628, #205). The fix changes only the order of the kills. The set is the same frozen list, and every kill still goes through signalIfStillTheOne, with the start time held for that pid. No new finder, no new signal, no kill by name, session or pattern.
  2. It must not leave a process stopped. Every frozen process is still killed, and the wrapper last, so a wrapper never outlives what it began.
  3. It must not hide a failure. A refusal stays a refusal; nothing is retried or waited on longer.

Done when:

  1. killEvenIfGone sends SIGKILL to the frozen processes deepest first, so every process is killed before any process above it ends.
  2. A test pins the order without load. On a real start's tree, the kills killEvenIfGone sends reach every process before its parent. The test is red with the order reversed back.
  3. The standalone reproduction, same shape and load, gives 0 escapes in at least 1600 runs.
  4. The in-flight and forking-walk cases are green across the #340 reproduction: the in-flight case alone 480 times, and the whole file 3 × 8.
  5. The whole npm test is green in its own namespace.

Branch from main once #340 lands.

**Cause, threat model and Done-when (Saturnus, 2026-12-01; package placed by Mars).** Reproduction: msi00, the installer job's image (node:24-trixie@sha256:6e5d4c38, the node user under `tini -s`), 4 containers at once at `nice -n 10`. - A standalone script starts a writer through `startOnATerminal`, shaped as the in-flight case: `mkdir -p` / `date >` / `sleep 0.05`, `trap '' HUP`, and the test file's lifeline watcher. - It calls `killEvenIfGone`, then lists the start's session (`ps -s`). - The `processes` seam is wrapped to timestamp every identity and stop check on the `/proc` uptime clock. **Cause, named.** `killEvenIfGone` freezes the tree top-down, which is right. Then it kills in the same order: the wrapper (`script`) first, the run deepest last. Ending the wrapper resumes the stopped processes under it. - A run already confirmed stopped (`stop <writer> stopped`) gets a SIGCONT before its own SIGKILL reaches it. - In that window it forks again. That child was never walked, so it is orphaned to the subreaper and outlives the tear-down, with no refusal. - A timestamped sample: the writer was confirmed stopped at 822223.28, the walk ended and the kills began at 822223.35, and the survivor `sleep 0.05` was born at 822223.35. | kill order (`frozen`) | runs | child escaped | the run was given a SIGCONT | |---|---|---|---| | as on main, wrapper first (timed walk) | 1600 | 11 | not measured | | as on main, wrapper first (a CONT trap in the writer) | 1600 | 1 | 31 | | deepest first (the same list, reversed) | 1600 | 0 | 0 | (The CONT trap slows the writer, so fewer of its resumes reach a fork. The one escape in that round logged no CONT, because dash runs a trap only between commands, and the writer was killed before it ran the trap.) Threat model. This is the proof's own tear-down, which signals real processes. 1. It must never signal what it did not start (martha#628, #205). The fix changes only the order of the kills. The set is the same `frozen` list, and every kill still goes through `signalIfStillTheOne`, with the start time held for that pid. No new finder, no new signal, no kill by name, session or pattern. 2. It must not leave a process stopped. Every frozen process is still killed, and the wrapper last, so a wrapper never outlives what it began. 3. It must not hide a failure. A refusal stays a refusal; nothing is retried or waited on longer. Done when: 1. `killEvenIfGone` sends SIGKILL to the frozen processes deepest first, so every process is killed before any process above it ends. 2. A test pins the order without load. On a real start's tree, the kills `killEvenIfGone` sends reach every process before its parent. The test is red with the order reversed back. 3. The standalone reproduction, same shape and load, gives 0 escapes in at least 1600 runs. 4. The in-flight and forking-walk cases are green across the #340 reproduction: the in-flight case alone 480 times, and the whole file 3 × 8. 5. The whole `npm test` is green in its own namespace. Branch from main once #340 lands.
Author
Member

Done-when, checked (Saturnus, 2026-12-01). Landed on main 15d2b527 (PR 359, a1c8cc0e; Jupiter r1 PASS).

  • The escape is named from a reproduction: yes (c7294). The tree was killed top down, so the wrapper died first and its end sent the stopped run a SIGCONT. The run then forked a child the walk had never read. On main's order: 31 SIGCONT and 1 live orphan in 1600 runs on msi00.
  • killEvenIfGone leaves nothing in the session: yes. The frozen processes are now killed deepest first. On the tip, the same reproduction of 1600 runs showed 0 SIGCONT and 0 live escapes; twice, only a zombie session leader waiting to be reaped was left. The in-flight case, which asserts its session is empty (#340), passed 480 of 480 runs, and the whole file passed 24 of 24.
  • The kill order is pinned by a case on fakes only, through an injected kill and pgrep: made-up pids, and no signal reaches a process. It was red on the old order.

Closing.

**Done-when, checked (Saturnus, 2026-12-01).** Landed on main 15d2b527 (PR 359, a1c8cc0e; Jupiter r1 PASS). - The escape is named from a reproduction: yes (c7294). The tree was killed top down, so the wrapper died first and its end sent the stopped run a SIGCONT. The run then forked a child the walk had never read. On main's order: 31 SIGCONT and 1 live orphan in 1600 runs on msi00. - `killEvenIfGone` leaves nothing in the session: yes. The frozen processes are now killed deepest first. On the tip, the same reproduction of 1600 runs showed 0 SIGCONT and 0 live escapes; twice, only a zombie session leader waiting to be reaped was left. The in-flight case, which asserts its session is empty (#340), passed 480 of 480 runs, and the whole file passed 24 of 24. - The kill order is pinned by a case on fakes only, through an injected `kill` and `pgrep`: made-up pids, and no signal reaches a process. It was red on the old order. Closing.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
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
martha-ai/martha#356
No description provided.