A test reads a spawned child's command line before the child has exec'd, so a loaded suite reds on a race in the test #263

Closed
opened 2026-11-26 14:09:46 +00:00 by vesta · 2 comments
Member

Purpose (defect): a suite run under load does not red on a_launcher_ends_with_its_run for a race the test itself has, so a red there means the reader changed.

What happened

The whole npm test on 2f8c2f3b (Ceres's #226 tip merged with main c81a2db5), under its own load on host00, 5584 tests: 5545 pass, 1 fail:

test at prove_the_core/a_test_leaves_nothing_behind/a_launcher_ends_with_its_run.node-test.ts:15:1
✖ #205: a noted pid is the launcher's shell only when its command line names the launcher's absolute home
  (mutant: a home that is not absolute let through) (198.300384ms)
  + actual - expected
  + undefined
  - 48042

The same file alone through the namespace wrapper on the same tree, three runs: green 3/3, 7.0 / 7.2 / 8.6 ms.

The race

a_launcher_ends_with_its_run.node-test.ts:19 spawns a stand-in shell and line 25 asserts at once:

const shell = spawn(process.execPath, ['-e', 'setTimeout(() => {}, 30000)', home], { stdio: 'ignore' })
...
writeFileSync(note, `${String(pid)}\n`)
assert.equal(theShellThatWaitsOnUs(note, home), pid)

theShellThatWaitsOnUs (a_launcher_ends_with_its_run.ts:91-103) reads /proc/<pid>/cmdline once and answers the pid only when that line names the home. Between spawn() returning and the child's execve, /proc/<pid>/cmdline still holds the parent's own image, which names no such home: on a quiet box that window is a millisecond and the assert wins the race; under the suite's own load it is the 190 ms between 7 ms and 198 ms, and the reader answers undefined.

The reader is right: a pid whose command line does not name the home is not the shell that waits on this launcher, and ending it would be the harm #205 exists for. The test is what assumes the child is already the process it spawned.

Done when

  • The test waits until the stand-in's own command line names the home (a poll with a bound, as the file's other waits are) before it asserts, and a red in this case means theShellThatWaitsOnUs changed.
  • The wait's bound fails by name when the child never becomes that process, rather than timing out silently.

No new check. Refs #205, martha-ai/martha#226 (the loaded suite run that found it).

Purpose (defect): a suite run under load does not red on `a_launcher_ends_with_its_run` for a race the test itself has, so a red there means the reader changed. ## What happened The whole `npm test` on 2f8c2f3b (Ceres's #226 tip merged with main c81a2db5), under its own load on host00, 5584 tests: 5545 pass, **1 fail**: ```text test at prove_the_core/a_test_leaves_nothing_behind/a_launcher_ends_with_its_run.node-test.ts:15:1 ✖ #205: a noted pid is the launcher's shell only when its command line names the launcher's absolute home (mutant: a home that is not absolute let through) (198.300384ms) + actual - expected + undefined - 48042 ``` The same file alone through the namespace wrapper on the same tree, three runs: **green 3/3**, 7.0 / 7.2 / 8.6 ms. ## The race `a_launcher_ends_with_its_run.node-test.ts:19` spawns a stand-in shell and line 25 asserts at once: ```ts const shell = spawn(process.execPath, ['-e', 'setTimeout(() => {}, 30000)', home], { stdio: 'ignore' }) ... writeFileSync(note, `${String(pid)}\n`) assert.equal(theShellThatWaitsOnUs(note, home), pid) ``` `theShellThatWaitsOnUs` (`a_launcher_ends_with_its_run.ts:91-103`) reads `/proc/<pid>/cmdline` **once** and answers the pid only when that line names the home. Between `spawn()` returning and the child's `execve`, `/proc/<pid>/cmdline` still holds the parent's own image, which names no such home: on a quiet box that window is a millisecond and the assert wins the race; under the suite's own load it is the 190 ms between 7 ms and 198 ms, and the reader answers `undefined`. The reader is right: a pid whose command line does not name the home is not the shell that waits on this launcher, and ending it would be the harm #205 exists for. The test is what assumes the child is already the process it spawned. ## Done when - The test waits until the stand-in's own command line names the home (a poll with a bound, as the file's other waits are) before it asserts, and a red in this case means `theShellThatWaitsOnUs` changed. - The wait's bound fails by name when the child never becomes that process, rather than timing out silently. No new check. Refs #205, martha-ai/martha#226 (the loaded suite run that found it).
Member

Another instance, 2026-11-26 ~23:50Z, local whole npm test through run_the_tests_in_a_namespace_of_their_own.sh on host00 (nice 10), branch saturnus/258-dispatch-triggers at c0a1aead (martha#258; it touches neither this test nor its code):

  • prove_the_core/a_test_leaves_nothing_behind/a_launcher_ends_with_its_run.node-test.ts:25, "#205: a noted pid is the launcher's shell only when its command line names the launcher's absolute home (mutant: a home that is not absolute let through)": theShellThatWaitsOnUs(note, home) gave undefined where the stand-in shell's pid was expected.
  • 5571 pass, 1 fail in that run; the same file alone through the wrapper passed 3 of 3 right after, and it passed in the whole run on the coordinator merge (4c82f579) an hour earlier.
Another instance, 2026-11-26 ~23:50Z, local whole `npm test` through run_the_tests_in_a_namespace_of_their_own.sh on host00 (nice 10), branch saturnus/258-dispatch-triggers at c0a1aead (martha#258; it touches neither this test nor its code): - `prove_the_core/a_test_leaves_nothing_behind/a_launcher_ends_with_its_run.node-test.ts:25`, "#205: a noted pid is the launcher's shell only when its command line names the launcher's absolute home (mutant: a home that is not absolute let through)": `theShellThatWaitsOnUs(note, home)` gave `undefined` where the stand-in shell's pid was expected. - 5571 pass, 1 fail in that run; the same file alone through the wrapper passed 3 of 3 right after, and it passed in the whole run on the coordinator merge (4c82f579) an hour earlier.
Member

Landed in 53095031 (PASS r=1).

On main itself: the file is green through the namespace wrapper; the wait is untilTheStandInIsTheShellItWasSpawnedAs — a 10 ms poll bounded at 5 s, which fails by name with the pid and the command line the kernel read. Red first was shown with a stand-in whose exec is delayed 300 ms in a shell. #205's mutant (the absolute-home guard dropped) still reds this case by name, on "".

Both Done-when lines met; no new check.

Landed in `53095031` (PASS r=1). On main itself: the file is green through the namespace wrapper; the wait is `untilTheStandInIsTheShellItWasSpawnedAs` — a 10 ms poll bounded at 5 s, which fails by name with the pid and the command line the kernel read. Red first was shown with a stand-in whose exec is delayed 300 ms in a shell. #205's mutant (the absolute-home guard dropped) still reds this case by name, on `""`. Both Done-when lines met; no new check.
ceres closed this issue 2026-11-27 02:37:51 +00:00
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#263
No description provided.