Skip to content

fix(jobs): reader-boundary notice pass retires without a retained link (Refs #4288) - #4290

Merged
caomengxuan666 merged 1 commit into
masterfrom
captain/4288-boundary-retire
Nov 30, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
captain/4288-boundary-retire

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #4288 — UNVERIFIED-BY-CAPTAIN

Root cause

kill -KILL %1; sleep 0.3; wait %1 answered 137 on master; GNU
answers 127 + wait: %1: no such job (oracle-verified against
bash 5.3.20, 3/3). The death is observed by the intervening
foreground wait, so at the wait line's reader pull the boundary
step (ast_exec flush, #2928) prints the notice, marks the job
notified, and its cleanup retires the entry — but that cleanup also
populates the #2777 retained link (completed_job_pids), and
wait's NoMatch arm consults the link and answers the saved status.

GNU's pull-driven notify_and_cleanup (parse.y shell_getc) deletes
the row in the same pass that prints the notice; no jobspec record
survives for the list being read. The link over-approximates GNU:
its legitimate domain is retirements driven mid-list (the
jobs builtin's own notify, a wait's tail cleanup), where a
following wait in the same list is the reap's peer — the #2777
cells. A retirement driven by the reader pull itself is not one
of those.

Fix

One shared cleanup, one flag:

  • jobs/table.rs: cleanup_dead_jobs delegates to
    cleanup_dead_jobs_impl(retain_link); new
    cleanup_dead_jobs_no_link() passes false (the entry-point
    completed_job_pids.clear() — link expiry — is unchanged).
  • executor/job_builtins.rs: emit_signal_notices delegates to
    emit_signal_notices_with_link(notices, retain_link); new
    report_pending_signal_notices_no_link(); the reader-boundary
    flush report_pending_signal_notices_at_line (both ast_exec
    call sites) routes through the no-link form.

Print timing, line stamps, J_NOTIFIED marking, and deletion are
all unchanged — only the link insert is skipped for the boundary
pass. Mid-list and stream-end passes keep the link.

What this PR deletes: nothing. The link mechanism stays for
its mid-list domain; the boundary pass uses the same single
cleanup impl with the record left unpopulated — no second path
is introduced.

Net lines: +50/−3 (2 production files; no test files — the
pin already exists and was red on master).

Approach considered and rejected (with evidence)

Moving the print itself to the foreground-wait notify point
(the original lane patch, +37/−1) fixes the wait outcome but
regresses the notice's placement and stamp: it prints before the
rest of the intervening list runs and stamps the just-finished
line (3), where GNU prints at the pull stamped with the upcoming
line (4). Evidence: three issue2769 stamp pins
(boundary_notice_stamps_the_next_commands_line,
…_the_first_line_read_after_the_death,
eof_notice_stamps_one_past_the_last_line) went red, and a
marker probe (sleep 0.3; echo MARKER on the intervening line)
showed the notice ahead of MARKER where the oracle prints it
after. The codebase's own #2928 comments already record this
GNU model; this PR leaves the print exactly where it was.

Verification (lane, devin-mac, base = master ef4ea1b0, real

target/debug/rubash throughout — never the bash shim)

  • Fail-first on base: the [A2-16] Killed job still listed by jobs after its death notice was printed #2698 script 6× → waitrc=137 6/6,
    one notice (stamp line 4), no no such job.
  • Post-fix: same script 6× → waitrc=127 + no such job 6/6,
    one notice, stamp still line 4. /bin/sleep 0.3 variant 127 6/6;
    echo SEP interposed 127 3/3; marker shape: MARKER, then the
    notice (line 4), then no such job, waitrc=127 — ordering,
    stamp, and outcome all identical to the oracle. One-line form
    (kill …; sleep 0.3; wait %1 in one list) stays 137 6/6, also
    matching GNU (the wait drain reaps mid-list; no pull retires).
  • Oracle side-by-side (bash 5.3.20): main case 127 / binsleep
    127 / SEP 127 / one-line 137 / stopped-then-killed E5 127 /
    interactive expire cell without an intervening echo (PTY):
    W=127, W2=127 — the fixed binary matches on every face.
  • issue2698_job_death_notice_retirement_regressions: 5/5
    (was 4/5 on master; the boundary test is the census red this
    fixes).
  • issue2769_death_notice_line_stamp_regressions: identical to
    base on this host (the 3 boundary/EOF stamp tests pass; the 2
    remaining reds are pre-existing environment failures, identical
    name set on base).
  • issue2777_stopped_job_state_regressions: identical name set
    patched vs base (both link cells pass; the 6 other reds are
    pre-existing devin-mac environment failures — BSD script has
    no -c, no controlling terminal — identical on base).
  • Risk-surface differential (17-target subset: aggregators
    2000_2299 / 2300_2499 / 2500_2699 / 2700_2799 / 3400_3599 plus
    the wait/jobs/notice standalone suites, run patched and on
    base on devin-mac): no unexplained delta. The only
    patched-vs-base differences were load flakes in signal-timing
    modules (issue2134 ×5, issue2346/2348/2352/2353 ×7), each of
    which passes on the patched tree in a quiet filtered re-run;
    the remaining local reds are identical environment failures on
    both sides, and issue2488's stopped-job wait test hangs on
    this host on both sides. Full-census differential is left to
    this PR's CI.

Residuals (deliberately out of scope)

…k (Refs #4288)

Refs #4288 (not Fixes).

A background death observed by an intervening foreground wait
was printed at the wait builtin's own reader boundary, and the
boundary emit's cleanup retired the job but also populated
the #2777 retained link (completed_job_pids) -- so
`kill -KILL %1; sleep 0.3; wait %1` answered 137 from the
link where GNU answers 127 + `no such job`. GNU's pull-driven
notify_and_cleanup (parse.y shell_getc) deletes the row in
the same pass it prints the notice; no jobspec record
survives for the list being read.

Give the cleanup a no-link form and use it for exactly the
reader-boundary pass: cleanup_dead_jobs delegates to a shared
cleanup_dead_jobs_impl(retain_link); the boundary report
(report_pending_signal_notices_at_line, the #2928 stamped
flush) routes through a new report_pending_signal_notices_
no_link / emit_signal_notices_with_link pair. Print timing,
stamps, marking, and deletion are unchanged -- only the
link insert is skipped. Mid-list retirements (the `jobs`
builtin's notify, a wait's own tail cleanup, the stream-end
flush) keep the link: there a following wait in the same
list is the reap's peer (#2777 cells).

Net lines: +50/-3 (2 production files; no test files -- the
pin already exists and was red on master). Nothing deleted:
the link mechanism stays for its mid-list domain; the
boundary pass now uses the same single cleanup impl with
the record left unpopulated, so there is no second path.
@caomengxuan666
caomengxuan666 merged commit 6753552 into master Nov 30, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant