Repository navigation
Description
Each shell runner under tools/ that starts a child with a time bound writes its own handling for the bound, for a signal, for the lease or lock it holds, for the child's descendants and for a failed cleanup. The same mistakes then come back in a neighbouring runner after one runner is fixed, and the reviews of #201 have kept finding the next one. This issue lists the mistakes as a checklist and the runners that still do their own handling, so the work can be seen as one piece. I will do it myself after the DGX Spark port (#53, P1 to P5) is done. I have no plan for the change yet, and I am not asking anyone else to do it.
What goes wrong
A runner starts a binary under GNU timeout while it holds a gate lock, a timing lease or an output pipe. If the runner is stopped, or its own bound ends, and the binary or its timeout is not ended with it, they keep those descriptors until their own bound (up to 900 s by default). Every later run that needs the lease or the lock then waits. #171 reported the first case. #201 fixes it for the gate runners and the timing runners it touches, by moving them to one run_bounded in tools/gate-bound.sh and the lease helpers in tools/ref/lease.sh.
The fix for one runner did not carry over to the others on its own, because each runner builds its own traps, pid bookkeeping and grace periods.
Why it keeps coming back
Each line is a kind of mistake. A line with a link was found in #201's public review or fixed in one of its commits. A line without a link I found while reviewing earlier heads of #201, before they were pushed; those are classes to test for, not open bugs.
- A sibling runner never goes through the shared owner and keeps its own
timeout(review of 572ee7b2, commit 5bcf6ad1, commit 2e69b336). - A runner starts the decoder under a background
timeoutof its own, and a stop reaches the runner but not the decoder (review of bbfa52b9, commit af2aae15). - A watcher forwards a signal to its monitor and not to the monitor's children (commit 38044f2f).
- A forwarding trap is set after the child starts, so a signal in between ends the runner alone (review of ddc585ca, commit 47407e36).
- A signal ends a
wait, the runner clears the child's pid, and the child is still shutting down (review of 8d11239e, commit ed37d072). - GNU
timeoutthat gets a TERM before it has returned fromforkexits without signalling its command (commit b9875e2b, commit b9f9f1ab). - A cleanup failure is dropped, so the runner returns success (review of dd64d463). Related: a later successful
waitoverwrites a cleanup status. - An output reader or FIFO that cannot be set up does not stop the run, and the reader is left running (commit c677d4ab, commit 1154890e).
- A filter on the output starts before its cancellation guard is in place.
- Group cleanup is sent to a job that never made a process group of its own, or to a
timeoutimplementation that does not make one. - Two supervisors, one inside the other, wait the same grace period and race.
- An EXIT handler that itself exits skips a cleanup appended after it.
Runners that still bound a child themselves
On upstream/main these start timeout themselves, in the foreground or the background, after lease_take or for a server they start. They are not among the files #201 changes, and they do not call run_bounded, lease_bounded or lease_capture. I found them by reading git grep output, not by cancelling each runner, so each may or may not leak. The check for each runner is the cancellation table below.
-
tools/ref/ncu-gpu.sh: threencuarms ("${CMD[@]}"undertimeout, afterlease_take). -
tools/ref/nsys-gpu.sh: thensys profilearms. -
tools/ref/nsys-ds41.sh: thensys profilearm. -
tools/ref/host-rate.sh: the thread sweep runs the bench undertimeoutwhile it holds the lease. -
tools/ref/lcpp-warm.sh:lcpp_srv_spawnstarts the llama.cpp server under a backgroundtimeout;tools/ref/depth-serve.shandtools/ref/depth-glm5next.shstart it through this helper.
The dump runners (dump.sh, dump-mtp.sh, dump-draft.sh) call lease_bounded, so they follow lease.sh once #201 merges. gate-batch.sh, mutant-run.sh and narrow-scan.sh also set their own traps and kill their own children. They supervise lanes and fixtures, not a bounded binary under a lease, and I have not looked at them for this issue.
A direction, not a plan
These are ideas to try, and none of them is decided.
- One owner for a bounded child: it makes the child's process group, installs cancellation before the child starts, collects the child's status and returns a cleanup error as its status. Callers would not write their own traps, pid bookkeeping or grace periods. tools: an ended gate run takes its binary's timeout with it #201 already puts the gate runners and the timing runners it touches behind
run_bounded; the work here would be to finish that boundary. - One shared cancellation table in the existing self-tests, covering six behaviours: a plain shell with a grandchild; a monitor that exits before its child; a child that ignores TERM; a stop at the boundary between launch and pid; a cleanup failure while the child's status is 0; and an output or FIFO setup failure. Each case asserts that the child and grandchild end, that the lock or lease is free, and what status comes back. The cases would wait for a readiness signal from the child instead of a longer
sleep. - A narrow static check, reached through the existing check-script tier, for the ways a runner can step around the owner: a direct
timeoutlaunch in a runner that holds a lease, an unhandledlease_stopstatus, and a second supervisor around an already supervised watch. It can only recognize a few patterns. It cannot prove process-group membership, trap timing or which status wins, so the cancellation table is what proves behaviour and the static check only guards the boundary. The Linux cancellation cases would need a Linux run, andjust mac-staticdoes not cover them.
I have no implementation plan beyond this yet.
Who and when
I will take this after the DGX Spark port (#53, P1 to P5) is done. Until then, my pull requests move to the shared owner only the runners they touch. I will turn this list into a plan before I start and post it here first.
AI help
AI 코딩 에이전트가 문제를 조사하고 재현해 이슈 초안을 썼습니다. 이슈 초안 리뷰는 제가 직접 했습니다.
Activity
gate-bound: bounded and bounded_bg own every runner's bounded child
midagedev commentedon Oct 22, 2026
Status (2026-10-22): #201 was closed, but its aim is on main: the owner (
bounded,bounded_bg, 5260c54), every runner moved to it (438bc48, 57545c4, 1781808), the static guardtools/check-bounded.shand the cancellation table (tools/gate-bound.sh --self-test). The five runners listed here now call the owner. @juliankang4: if a class on your list is not covered by the table, name it; otherwise we close this.juliankang4 commentedon Oct 22, 2026
I checked each class on the list against
tools/gate-bound.sh --self-testandtools/check-bounded.shon main (b058374). All twelve have a case in the cancellation table or a rule in the guard, and the five runners on the list call the owner:ncu-gpu.sh,nsys-gpu.sh,nsys-ds41.shandhost-rate.shthroughlease_bounded, andlcpp-warm.shthroughbounded_bg, whichdepth-serve.shanddepth-glm5next.shuse to start the server. On main the cancellation table endsok (0 failures), andcheck-bounded.shand its self-test both pass. I ticked every box and am closing this.One case is outside the owner:
tools/narrow-scan.shbounds and stops its runner on the box with its owntimeoutand pid file, and a stop that arrives before the pid is written signals nothing there. It is now an item in #637.(AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.)