Repository navigation
tools: load-groups.sh kills a process that prints nothing for BOUND seconds - #169
Conversation
…econds lg_process read the status of read -t after a negated test, so st was always 0 and the st > 128 kill branch never ran: a stalled grouped arm waited at wait "$pid" for the outer timeout, BOUND x (arms + 1), with the timing lease held. read's own status is kept now, so an idle bound ends the process and EOF still just ends the loop. The self-test drives lg_process on a process that stalls after its arm line and checks that its timeout ended with 143, the idle bound's TERM, and not with 124, the outer bound. A host with no timeout gives that case and gpu-gate.sh's self-test one stand-in, tools/ref/stub-timeout.py, which ends 124 at its bound and passes a TERM on to the command as coreutils does, and leaves no process behind; gpu-gate.sh's inline one is gone.
There was a problem hiding this comment.
Verdict: CLEAN: The idle bound now uses read's status, and the new assertions reject the reported defect.
Checked
Duplicates: 5 new named functions checked; the callback overrides are test fixtures, and the timeout stand-in replaces its inline owner. No duplicates found; no dryer pairs available.
Complexity: No Rust functions changed.
Silent failure: 3 paths followed: failed read, child termination, and deadline expiry. Their statuses reach the caller's failure handling.
Tests: The stall assertions pass in an in-memory pipe harness. In tools/ref/load-groups.sh:171, restoring the negated read turns them red. Dropping the diagnostic (:174), idle kill (:175), or remaining-arm assignment (:235) also turns an assertion red. Normal EOF completes with rc 0. The stand-in returns 0, 124, and 143 for normal exit, its deadline, and TERM respectively.
Gates: None relaxed or removed. The added stall case has FAIL-first evidence in the PR body.
Escape catalog: No C1–C4 patterns match the added lines.
Performance: Tool and self-test code only; no inference hot path changed.
Notes
Dryer and crapper did not run because no Rust file changed.
Full self-tests were not run; runtime probes used pipes instead of temporary FIFO files.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
Filed outside this PR: #171
|
The review is done and the contribution check passed, so I'm merging this. |
What and why
In
lg_process(tools/ref/load-groups.sh),if ! IFS= read -r -t "$BOUND" ...; then st=$?stores the status of the negated test, sostis always 0 and the[ "$st" -gt 128 ]branch, which prints "no line for N s; killing the process" and kills the process, never runs. A grouped arm that stalls without printing a line is not killed afterBOUNDseconds as the header promises.wait "$pid"blocks until the outertimeoutends the process,BOUND x (arms + 1)seconds after the start, with the timing lease held the whole time. Closes #119.The change:
st=0andIFS= read ... || st=$?keepread's own status, and the branch tests[ "$st" != 0 ]. A timeout (above 128) kills the process as intended; the end of the stream (status 1) still just leaves the loop.The
--self-testof the file ran only the grouping and the order. It now also driveslg_processon a process that prints itsarmline and then stalls, with three arms in the unit. The process'stimeouttells the two ends apart without a clock: the idle bound'skillsends it a TERM, which it passes to the process, and it ends 143; the outer bound would end it 124. The case checks that the idle-bound message is printed once, that the stalled arm ends with rc 143, and that the two arms behind it are left for a fresh load.BOUNDis one second scaled with the host's load bytools/bloomery/selftest.py(load_cap), so a loadedcheck-recipesrun does not miss the first line.lg_processopens its descriptors withexec {fd}<>, which needs bash 4.1, so under the macOS bash 3.2 the case printsskip stalland the rest of the self-test runs as before.A host with coreutils
timeout(Linux, CI) runs the case under it. A host with none (the Mac) needs a stand-in, andtools/gpu-gate.sh --self-testalready wrote one inside its function (:408-412atfadec9d0), which this case could not call. That one also died on a TERM and left its command running. So the stand-in becomes one file,tools/ref/stub-timeout.py, besidestub-llama-server.py, and both self-tests copy it in astimeoutwhencommand -v timeoutfinds none. It is not intools/ref/card-tests/bin/, becausecard-tests/run.shputs that folder onPATHon a host with noflock, and atimeoutthere would change the card-tests that check for one (lease.sh,depth-serve.sh). It takestimeout [--kill-after=K] S COMMAND...and ends the two ways coreutils does: 124 at its bound, with the command killed, and the command's status (143 for a TERM) when it is sent a TERM, which it passes on. It leaves no process behind, so the end of the stream reaches the reader when the command ends. The stand-in sits in one shared file because otherwise the inline stand-in ingpu-gate.shand the new case would each carry a copy of the same code. The net change is the same as with a second copy inload-groups.sh, 15 lines:gpu-gate.shgoes from 5 lines to 1 that copies the file in, the file has 18 (a 3-line docstring among them), andload-groups.shreaches it in one line, where a second copy took 15.tools/check-recipes.sh's comment on the load-groups block said the self-test starts no process; it now says what the self-test covers.Code shape
readis fixed in place, and thetimeoutstand-in has one owner,tools/ref/stub-timeout.py, for both self-tests that need one.gpu-gate.sh's inline stand-in is removed.check-recipes.shblock comment name what the self-test covers.cargo fmtandcargo clippyare clean on what I touched; no Rust file is touched.Duplication found or removed (
path:line), or "none": thetimeoutstand-in oftools/gpu-gate.sh(:408-412atfadec9d0), nowtools/ref/stub-timeout.py, which the new case uses too.What I ran
FAIL first.
lg_processoffadec9d0with this commit's self-test, on a Mac with bash 5.3.20:The mutant the case has to catch: this commit's file with only the idle bound's
kill "$pid"line removed endsFAIL stall-term: got [post 0 rc=124], want [post 0 rc=143], because the outer bound then ends the process. The case does not depend on how long either run takes. With this commit:/bin/bash tools/ref/load-groups.sh --self-test(3.2.57):skip stall: bash 3.2.57(1)-release has no exec {fd}<>, thenself-test: ok (0 failures).tools/gpu-gate.sh --self-test, which takes the shared stand-in on this Mac (it has notimeout):gpu-gate self-test: 99 of 99 okunder bash 3.2.57 and under bash 5.3.20.sleepis left afterwards.bash tools/check-comments.sh: ok.shellcheck -xonload-groups.sh,gpu-gate.shandcheck-recipes.sh: no new finding.just mac-static fadec9d0on a second Mac (Apple M5):mac-static: ok, check-recipes rc 0 (127 s, its blocks run 3 at a time on that Mac;gpu-gate self-test: 99 of 99 okinside it), combos 0 shapes run and 49 skipped as out of scope. The check ran on this PR's head, rebased onfadec9d0.Not run here: the case under coreutils
timeout, which only Linux has (CI'sjust contrib-check --tier t0on Ubuntu runs it, throughtools/check-recipes.sh), and a grouped arm that stalls underdepth-ds41.shordepth-qwen3moe.shon the box. The driver's code path is the one the self-test drives, with a stand-in for the binary.Hardware (if the change is for a machine)
None. A Mac (Apple M4 Pro, macOS 27) with the system bash 3.2.57 and bash 5.3.20 from Homebrew, and a second Mac (Apple M5) for
just mac-static.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.