Clean-install and launch tests leave processes and trees on host00 for days: a killed run runs no tear-down #70

Open
opened 2026-11-22 23:29:03 +00:00 by pluto · 3 comments
Member

Purpose (defect): no test leaves a process, a session or a tree behind on the machine after its run ends, however the run ends: pass, fail, SIGTERM, SIGKILL or --test-force-exit.

What is left today

Read from /proc on host00, 2026-11-23 ~00:45Z. Every one is reparented to pid 913 and sits in a session of its own, so no walk from a test can reach it any more:

pid age what it is
1662922 5.02 d sh -c ... while :; do mkdir -p /tmp/martha-clean-install-test-Dnn4Q7/relay; date > ...
1666023 5.02 d script --quiet --return --command /tmp/martha-clean-install-test-RTQGTg/writer.sh /dev/null
1666024 5.02 d /bin/sh /tmp/martha-clean-install-test-RTQGTg/writer.sh
1666026 5.02 d the while :; do ... sleep 300 & ... loop that writer.sh started
2810917 3.75 d node /tmp/martha-cc-launch-fdnSKy/launcher.ts
92222 3.73 d node /tmp/m724-NmlUp1/fa319/martha-cc-launch-7ErC7Y/launcher.ts
218285 3.73 d node /tmp/m724-8PJ1GA/f3a22/martha-cc-launch-UGkx78/launcher.ts
2095385 3.70 d node /tmp/m724-t8dGPI/f7883/martha-cc-launch-epdIK6/launcher.ts

Their trees are still on disk with them: the martha-clean-install-test- directories hold writer.sh, forker.sh and a relay root being written to, and the martha-cc-launch- homes hold a launcher's files.

Why the tear-down never ran

Both files take their processes down in t.after, and the clean-install file's martha#590 cases walk the session and kill it; the launcher file holds a lifeline pipe (martha#559) that a launcher reads to its end. All of that runs inside the test's own process. When the run is killed, nothing of it runs: t.after never fires, the shell loop never reads anything, and the processes are reparented away in sessions script made for them, which no group kill of the test's own group reaches. The tree then stays too, because the code that removes it is in the same t.after.

Two things make it worse than a one-off: the forker loop writes a relay root forever, and the launchers ignore SIGTERM (a plain kill does not end them), so an operator clearing the box by hand has to reach for SIGKILL.

Done when

  • Every process a test starts ends when its run ends, however it ends. The end of the run must reach them, not the patience of the tear-down.
  • Every tree a test made is removed the same way.
  • A red-first test proves it: a run that is killed the way CI kills one leaves no process and no tree, and that test is red on main today.
  • No new check (B11).

Not this issue: macula-io/martha#3, the clean-install proof's red with an empty builder screen. Its comments name no leftover process and it flips green on tips that never touch this code, so it stays its own package.

Refs macula-io/martha#559, #590, #724, #3.

Purpose (defect): no test leaves a process, a session or a tree behind on the machine after its run ends, however the run ends: pass, fail, SIGTERM, SIGKILL or --test-force-exit. ## What is left today Read from /proc on host00, 2026-11-23 ~00:45Z. Every one is reparented to pid 913 and sits in a session of its own, so no walk from a test can reach it any more: | pid | age | what it is | |---|---|---| | 1662922 | 5.02 d | `sh -c ... while :; do mkdir -p /tmp/martha-clean-install-test-Dnn4Q7/relay; date > ...` | | 1666023 | 5.02 d | `script --quiet --return --command /tmp/martha-clean-install-test-RTQGTg/writer.sh /dev/null` | | 1666024 | 5.02 d | `/bin/sh /tmp/martha-clean-install-test-RTQGTg/writer.sh` | | 1666026 | 5.02 d | the `while :; do ... sleep 300 & ...` loop that writer.sh started | | 2810917 | 3.75 d | `node /tmp/martha-cc-launch-fdnSKy/launcher.ts` | | 92222 | 3.73 d | `node /tmp/m724-NmlUp1/fa319/martha-cc-launch-7ErC7Y/launcher.ts` | | 218285 | 3.73 d | `node /tmp/m724-8PJ1GA/f3a22/martha-cc-launch-UGkx78/launcher.ts` | | 2095385 | 3.70 d | `node /tmp/m724-t8dGPI/f7883/martha-cc-launch-epdIK6/launcher.ts` | Their trees are still on disk with them: the `martha-clean-install-test-` directories hold writer.sh, forker.sh and a relay root being written to, and the `martha-cc-launch-` homes hold a launcher's files. ## Why the tear-down never ran Both files take their processes down in `t.after`, and the clean-install file's martha#590 cases walk the session and kill it; the launcher file holds a lifeline pipe (martha#559) that a launcher reads to its end. All of that runs inside the test's own process. When the run is killed, nothing of it runs: `t.after` never fires, the shell loop never reads anything, and the processes are reparented away in sessions `script` made for them, which no group kill of the test's own group reaches. The tree then stays too, because the code that removes it is in the same `t.after`. Two things make it worse than a one-off: the forker loop writes a relay root forever, and the launchers ignore SIGTERM (a plain `kill` does not end them), so an operator clearing the box by hand has to reach for SIGKILL. ## Done when - Every process a test starts ends when its run ends, however it ends. The end of the run must reach them, not the patience of the tear-down. - Every tree a test made is removed the same way. - A red-first test proves it: a run that is killed the way CI kills one leaves no process and no tree, and that test is red on main today. - No new check (B11). Not this issue: macula-io/martha#3, the clean-install proof's red with an empty builder screen. Its comments name no leftover process and it flips green on tips that never touch this code, so it stays its own package. Refs macula-io/martha#559, #590, #724, #3.
Author
Member

The fixture was a fork bomb of its own, and the walk missed what it forked

Raf, as Mars relayed it (2026-11-23): "FFS save the CPU!" — 58,798 orphaned sleeps were found on host00.

The runaway fixture as main has it keeps every child it ever forks: while :; do sleep 300 & sleep 300 & sleep 0.005; done
starts about 400 processes a second and reaps none, so one run that is killed (and so runs no t.after) leaves thousands
behind, and each of them slows the /proc scan behind every pgrep for every other run on the box.

Branch pluto/70-leaked-processes does four things:

  • Bounded fixture. The forking loop keeps at most FORKS_KEPT (8) long-lived children at once, each new child replacing
    the oldest. Measured in a container: 8-9 children of the loop and 11 sleep 300 processes in total, steady.
  • The run's end reaches the start. The test file holds the writing end of a named pipe for as long as its run exists;
    when that end comes — timeout, session end, --test-force-exit, SIGKILL — the start stops what it began, kills it with
    the children it had at that moment, removes its tree, and lets the wrapper end. The same end the test process itself is
    held to (martha#683), one level further out.
  • The walk waits for the stop it sends. Bounding the fixture exposed this: SIGSTOP is a request the kernel takes at
    the process's next return to user space, and the walk read children as soon as it had sent the stop. A child forked in
    that window was in no read, and its parent's death handed it on, out of every later walk — the exact leak this issue is
    about, one process at a time. The walk now reads a process's children only once the machine says it is stopped (or
    gone), bounded, and refuses by name when the machine cannot say. That answer comes from the host contract's new
    stopOf, so the installer restates no /proc field.
  • The walk keeps its teeth. A child born during a walk still outlives the walk, so martha#590 r=1 still
    discriminates: by mutation, reading children before the freeze fails r=1 (30.2 s) and the r=3 record case, dropping
    the wait fails the new pin, and dropping the lifeline fails the new martha#70 case with "nothing the start began is
    alive once the run has gone".

The launcher half of this issue is #472/#559's own lifeline, which already ends a launch with its run; the four launcher
pids in the table predate it and are that lifeline's business. Nothing here touches it.

## The fixture was a fork bomb of its own, and the walk missed what it forked Raf, as Mars relayed it (2026-11-23): "FFS save the CPU!" — 58,798 orphaned sleeps were found on host00. The runaway fixture as main has it keeps every child it ever forks: `while :; do sleep 300 & sleep 300 & sleep 0.005; done` starts about 400 processes a second and reaps none, so one run that is killed (and so runs no `t.after`) leaves thousands behind, and each of them slows the `/proc` scan behind every `pgrep` for every other run on the box. Branch `pluto/70-leaked-processes` does four things: - **Bounded fixture.** The forking loop keeps at most FORKS_KEPT (8) long-lived children at once, each new child replacing the oldest. Measured in a container: 8-9 children of the loop and 11 `sleep 300` processes in total, steady. - **The run's end reaches the start.** The test file holds the writing end of a named pipe for as long as its run exists; when that end comes — timeout, session end, `--test-force-exit`, SIGKILL — the start stops what it began, kills it with the children it had at that moment, removes its tree, and lets the wrapper end. The same end the test process itself is held to (martha#683), one level further out. - **The walk waits for the stop it sends.** Bounding the fixture exposed this: `SIGSTOP` is a request the kernel takes at the process's next return to user space, and the walk read children as soon as it had sent the stop. A child forked in that window was in no read, and its parent's death handed it on, out of every later walk — the exact leak this issue is about, one process at a time. The walk now reads a process's children only once the machine says it is stopped (or gone), bounded, and refuses by name when the machine cannot say. That answer comes from the host contract's new `stopOf`, so the installer restates no `/proc` field. - **The walk keeps its teeth.** A child born during a walk still outlives the walk, so martha#590 r=1 still discriminates: by mutation, reading children before the freeze fails r=1 (30.2 s) and the r=3 record case, dropping the wait fails the new pin, and dropping the lifeline fails the new martha#70 case with "nothing the start began is alive once the run has gone". The launcher half of this issue is #472/#559's own lifeline, which already ends a launch with its run; the four launcher pids in the table predate it and are that lifeline's business. Nothing here touches it.
Member

A note from the martha#82 fix (PR 95, Mars's fable review, record martha PR 95 c1459). It goes here by Supervisor ruling, as a comment, not a package.

The host contract test now reads the adapter's processes from thisMachine.processes, so it no longer goes stale when a part is added. One mutant still survives: if the DEFINITION itself loses stopOf (src/linux_process_identity/files_and_processes_on_this_machine.ts), the test stays 35/35 and tsc stays at 0, because stopOf? is optional (src/host_contract/host_contract.ts:438). The old four-item literal never pinned it either.

At 5f67fa11 there is no caller of processes.stopOf under src, prove_the_core or architecture. Whoever adds the caller this issue needs owns the guard the typedef doc names: a caller that needs stopOf refuses by name when it is absent, with a test that deletes stopOf from the definition and reads that refusal.

A note from the martha#82 fix (PR 95, Mars's fable review, record martha PR 95 c1459). It goes here by Supervisor ruling, as a comment, not a package. The host contract test now reads the adapter's processes from `thisMachine.processes`, so it no longer goes stale when a part is added. One mutant still survives: if the DEFINITION itself loses `stopOf` (src/linux_process_identity/files_and_processes_on_this_machine.ts), the test stays 35/35 and tsc stays at 0, because `stopOf?` is optional (src/host_contract/host_contract.ts:438). The old four-item literal never pinned it either. At 5f67fa11 there is no caller of `processes.stopOf` under src, prove_the_core or architecture. Whoever adds the caller this issue needs owns the guard the typedef doc names: a caller that needs `stopOf` refuses by name when it is absent, with a test that deletes `stopOf` from the definition and reads that refusal.
Member

Red on host00, twice, not the linked-TMPDIR run's fault (unverified beyond this box)

While proving macula-io/martha#98 on host00 (an ordinary node --test of a file in this suite, no TMPDIR trickery) this
test went red, and again when run alone:

$ cd installer && nice -n 10 env -u TMPDIR node --test --test-timeout=60000 --test-force-exit 'prove_a_clean_install/prove_a_clean_install.node-test.mjs'
✖ a start on a terminal ends with the run that started it, and takes its tree with it (martha#70) (242ms)
  AssertionError: the run had forked children before it went
      at prove_a_clean_install.node-test.mjs:730:10
ℹ tests 45  ℹ pass 44  ℹ fail 1

It passed on the forge runner in the same shape (martha#98's task 5706: the second suite run there had exactly one fail,
the #48 clone-notice test), so this looks host00-local. pgrep is not the cause: pgrep -P names a known child here
(procps-ng 4.0.7). Unverified guess: the fixture writes its pid file before its first sleep 300 &, so on a slow or
loaded box childrenOfTheRun can read no children yet.

Red on host00, twice, not the linked-TMPDIR run's fault (unverified beyond this box) While proving macula-io/martha#98 on host00 (an ordinary `node --test` of a file in this suite, no TMPDIR trickery) this test went red, and again when run alone: ``` $ cd installer && nice -n 10 env -u TMPDIR node --test --test-timeout=60000 --test-force-exit 'prove_a_clean_install/prove_a_clean_install.node-test.mjs' ✖ a start on a terminal ends with the run that started it, and takes its tree with it (martha#70) (242ms) AssertionError: the run had forked children before it went at prove_a_clean_install.node-test.mjs:730:10 ℹ tests 45 ℹ pass 44 ℹ fail 1 ``` It passed on the forge runner in the same shape (martha#98's task 5706: the second suite run there had exactly one fail, the #48 clone-notice test), so this looks host00-local. `pgrep` is not the cause: `pgrep -P` names a known child here (procps-ng 4.0.7). Unverified guess: the fixture writes its pid file before its first `sleep 300 &`, so on a slow or loaded box `childrenOfTheRun` can read no children yet.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
3 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
martha-ai/martha#70
No description provided.