A test's cleanup kills a pid by number, so a reused pid would name another process #261

Open
opened 2026-11-26 12:43:21 +00:00 by vesta · 0 comments
Member

Purpose (defect): a kill in martha's own test files names only the process the file recorded, never whichever process happens to hold that number later.

prove_the_core/a_test_run_keeps_one_temporary_root/keep_a_test_run_in_one_temporary_root.node-test.ts, in theLoopAt:

t.after(() => {
  if (isRunning(loop)) process.kill(loop, 'SIGKILL')
  removeTheTree(temp)
})

loop is a number read from a file, and isRunning reads /proc/<pid>/stat's state letter alone: it answers whether something runs at that number, never whether it is the loop the run started. Inside a test run's own pid namespace, a number handed out again names another process of the same run — a wrapper, a stand-in, another case's child — and the cleanup then kills a process this check never started.

That is the class martha#220 closes in the product (a session id read while the terminal ran, killed after its leader is gone), and what martha#205's rule forbids of a test: no kill past what the file itself started. The loop's other reads have the same shape — :540 ("the loop went with the killed run") and :544 ("still running after the next run") ask whether something is at that number, not whether the loop is still the one at it.

Instance: not observed. The window is a pid reused inside one namespace, which martha#222 and martha#248 already show this box can lose races to.

Done when: a kill, and a liveness check, in these cases name the process the file recorded — for example by recording the identity (the boot and the start ticks that src/linux_process_identity reads) where the pid is first seen, and comparing it at the kill — with a case proving that a number another process took is neither killed nor read as the loop.

No new check: the shape lives in these files, not in a job.

Refs martha-ai/martha#220, martha-ai/martha#216, martha-ai/martha#205, martha-ai/martha#222, martha-ai/martha#248.

Purpose (defect): a kill in martha's own test files names only the process the file recorded, never whichever process happens to hold that number later. `prove_the_core/a_test_run_keeps_one_temporary_root/keep_a_test_run_in_one_temporary_root.node-test.ts`, in `theLoopAt`: t.after(() => { if (isRunning(loop)) process.kill(loop, 'SIGKILL') removeTheTree(temp) }) `loop` is a number read from a file, and `isRunning` reads `/proc/<pid>/stat`'s state letter alone: it answers whether *something* runs at that number, never whether it is the loop the run started. Inside a test run's own pid namespace, a number handed out again names another process of the same run — a wrapper, a stand-in, another case's child — and the cleanup then kills a process this check never started. That is the class martha#220 closes in the product (a session id read while the terminal ran, killed after its leader is gone), and what martha#205's rule forbids of a test: no kill past what the file itself started. The loop's other reads have the same shape — `:540` ("the loop went with the killed run") and `:544` ("still running after the next run") ask whether something is at that number, not whether the loop is still the one at it. Instance: not observed. The window is a pid reused inside one namespace, which martha#222 and martha#248 already show this box can lose races to. Done when: a kill, and a liveness check, in these cases name the process the file recorded — for example by recording the identity (the boot and the start ticks that `src/linux_process_identity` reads) where the pid is first seen, and comparing it at the kill — with a case proving that a number another process took is neither killed nor read as the loop. No new check: the shape lives in these files, not in a job. Refs martha-ai/martha#220, martha-ai/martha#216, martha-ai/martha#205, martha-ai/martha#222, martha-ai/martha#248.
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#261
No description provided.