Repository navigation
fix(jobs): wait %N reaches the saved status of a notified dead job (Refs #2777) - #3463
Conversation
…2777) GNU wait_for_job (jobs.c:3401) reads the job's slot, which survives until the wait consumes it (marked J_NOTIFIED, jobs.c:3434-3437). Rubash deletes the slot at notification cleanup (cleanup_dead_jobs) but keeps the exit status in completed_statuses (the bgpids equivalent), so an explicit wait %1 issued after the Killed notice printed answered 127 'no such job' for a job the shell already reaped. Retain the retired job-id -> last-pid link at cleanup and let the operand-wait path fall back to it; wait_for_background_pid then answers 137 from the saved status. Disown paths never populate the link and only the operand-wait path consults it, so kill/fg/bg and wait after disown keep GNU's 127 on a deleted slot (wait.def:294-311). The nail's exact W=137 assertion is widened to GNU's legal set {137,147}/{137,148}: the 5.3.20 oracle itself races between 137 and 147 on the nail's own cell (probe-gnu-w.sh form A, 137x2 / 147x4); only 127 is outside GNU's value set. Refs #2777
The retired-link fallback in wait_for_background_operands was unreachable: execute_wait_inner only takes that route when some operand resolves through the live table (resolve_background_job), so a wait %1 for an already-notified job fell through to the single-word fallback, which can only answer 127. Count a retired %N (retained job-id -> pid link, status saved) as resolvable for the gate; the operand path then answers 137 from completed_statuses, exactly as for a live Completed entry. Refs #2777
队长复核:FAIL(返工 2 项 + 补钉)复核基线:head 但队长三方探针(GNU 5.3.20 / base / head,同一脚本
GNU 的记录只活过「注意到死亡的那一轮清扫」:下一轮清扫(隔一行命令,格 B)或一次消费性的 wait(格 E)之后, 返工项:
另:lib base 失败名集合本轮欠账(box 盘满 os error 28 与本地 EDQUOT 各 VOID 一次,均为环境面);head lib 零失败,列为重审轮补跑项,不阻塞本次裁决。完整档案见 Refs #2777 |
…suming wait (Refs #2777) GNU keeps no jobspec record for a row deleted at notification cleanup or consumed by an operand wait (jobs.c:1303 cleanup_dead_jobs, jobs.c:3434-3437 wait_for_job J_NOTIFIED). The completed_job_pids link now expires at the next cleanup_dead_jobs round and rows already answered by an explicit wait (wait_consumed) leave no link, so one intervening line or a second 'wait %N' answers 127 like GNU. Pin adds the captain's B (expiry) and E (consumption) cells.
|
【WIN-AGENT-AUDIT】 机制核查(GNU 锚点):
腿:
F 点(队长 R 项逐条):
未跑/VOID 的腿:
续作记录: |
|
【WIN-AGENT-REWORK】 PR #3463 第3轮 — 建议:PASS(缺腿补齐,3 红钉格判环境绑定) 本轮补腿(WSL Linux /root/rubash-wsl,CARGO_INCREMENTAL=0):
未动代码。判词翻 PASS,按协议 squash 合并。 |
根因
kill -KILL %1之后紧跟的wait %1在 rubash 上竞速报 127no such job:死讯在 wait 行前的 pre-refresh 里已被 reap,行切换 flush 印出 Killed 通知后cleanup_dead_jobs删了作业表条目,而%解析只查活表——状态(137)明明还躺在completed_statuses(bgpids 等价物)里,作业号到 pid 的链接却随条目一起丢了。追踪定链(box 追踪二进制,pct cell ×5):4 次 STASH 路径(fresh_fatal 为真,条目留表 Completed)→ W=137;1 次 APPLY 路径(fresh_fatal 为假,当场 apply 后通知+清理删条目,wait 入口
jobs=[] completed=[pid])→ W=127。链 A 确立,链 B 排除。GNU 锚点
jobs.c:3401 wait_for_job:读作业槽位,wait 消费后才标 J_NOTIFIED(jobs.c:3434-3437);槽位在 wait 到达前一直都在。builtins/wait.def:294-311:%操作数走get_job_spec,槽位已删才 127;有记录的死作业回落 bgpids 已存状态,不报 127。jobs.c:2863-2866 wait_for_background_pids尾部bgp_clear():裸waitwholesale 清掉已存状态——本修法在clear_completed_statuses里同步清掉保留链接,127 在该处如数保留。修法
src/jobs/table.rs:新增JobTable.completed_job_pids(作业号 → 末 pid),仅cleanup_dead_jobs(通知清理)在删条目时填入,且仅当该 pid 在completed_statuses里有已存状态;clear_completed_statuses(bgp_clear)与clear_jobs(disown -a / delete_all_jobs)同步清空;新作业复用该号时清除旧链接。src/executor/job_builtins.rs:仅操作数wait路径(wait_for_background_operands)在%N活表无果时回落该链接,仍走wait_for_background_pid(已存状态 → 137;状态已被清 → NotFound → 127)。kill/fg/bg与 disown 后wait %N保持活表-only,仍报 GNU 的 127。W=137精确断言放宽为 GNU 合法集——SIGSTOP 格{137,147}、TSTP 格{137,148}。GNU 5.3.20 自身在钉的精确 cell 上竞速(probe-gnu-w.sh形 A,piped -i,6 次:137×2、147×4);只有 127 在 GNU 值集之外。jobs列表 Stopped 断言不动。本 PR 删除了什么
什么也没删除。只新增:
JobTable一个保留映射字段及三处同步清理、操作数 wait 一处回落分支、钉两处断言放宽。无公开面变动,无文件删除。验证(队长复核前)
RUSTFLAGS="-D warnings"、卫生三项。UNVERIFIED-BY-CAPTAIN
Refs #2777