Repository navigation
fix(executor): adopt respawn provenance via fd/pipe proof for subreaper orphans (Refs #3300) - #3652
Conversation
…er orphans (Refs #3300) Every fork-shaped respawn (async, coproc, both process-substitution forms) mints a fresh anonymous pipe holding a fresh 16-byte nonce, closes the write end before spawn, and hands the child the read end at a spawner-chosen number >= 100 plus two per-spawn keys (__RUBASH_RESPAWN_PROOF_FD / __RUBASH_RESPAWN_PROOF). The child's entry validates the pipe exactly once (FIFO + O_NONBLOCK + 16 bytes == nonce + EOF) and the orphan branch opens when the proof is valid and the stamped spawner is gone. A child orphaned to a live unrelated parent (a subreaper) now adopts its spawner provenance instead of falling back to a re-parsed body line. GNU: execute_cmd.c:1576 execute_in_subshell, subst.c:6362 process_substitute — the forked child keeps the definition line regardless of when its parent exits. Pins: tests/issue3300_subreaper_orphan_regressions.rs (5 cells, all assert the reparenting shape: PPID == harness pid, SUB == 1, PID == spawner pid).
|
【WIN-AGENT-AUDIT】 机制核查:
腿(本轮在 WSL Linux(x86_64, rustc 1.98.1) 上补跑,Unix-only 形状只有 Linux 可复现;Windows 侧只做编译/警告腿):
F 点:
续作记录:本轮未动代码(按分工,FAIL 只发报告)。 |
|
【WIN-AGENT-AUDIT】 机制核查:
腿(逐项给数字与名字,均为 Linux/WSL 实测):
F 点:无(上轮两条跨目标编译 F 点已消除,见续作记录) 续作记录:
未跑/VOID 的腿:
|
|
【WIN-AGENT-AUDIT】 head: 2c66f4a(未变)base(merge-base): 6171293 机械解尝试记录:
腿:本轮为冲突裁定轮,未重跑构建腿(head 未变;第 2 轮 Linux 全腿绿结论存档:钉 5/5、fail-first 4 红名一致、邻钉 68 例、GNU subreaper harness 逐字段一致)。 |
Conflict resolution against master's #3049 provenance refactor: - src/executor/init.rs: master decides `internal_respawn` on the RAW env before import (the transport family must be stripped before from_values). The local recomputation the PR carried at the later site is dropped (master's comment stands); the proof verdict joins the early call as its third argument, `respawn_proof_validated()` (OnceLock-cached, so both entry paths see one verdict). - src/executor/compound_exec.rs: keep the PR's proof mint (first, before any carrier dup) and take master's `test_rubash_binary_from_env()` exe resolution, which replaced the inline CARGO_BIN_EXE lookup. Semantics unchanged: `respawn_provenance_validated` keeps master's two ppid arms verbatim and only the live-unrelated-parent arm consults the per-spawn fd/pipe proof, still together with `stamped_spawner_gone`.
|
【WIN-AGENT-AUDIT】 机制核查(解法与第3轮 abort 时给出的唯一正确解一致):
腿(WSL Linux x86_64, cargo 1.98.1, 树 /root/rubash-e2 @ 96dcd34):
F 点:无。 说明:本 merge commit 由 caomengxuan666 账号于 17:12 +08 推送(解法与第3轮给出的唯一正确解逐点吻合);本 lane 只做只读复核+WSL 实测,未动分支。若队长侧另有在途验证,以其为准。 未跑/VOID 的腿:无。 |
UNVERIFIED-BY-CAPTAIN
摘要
rubash #3300:后台函数体重解析行戳取决父进程退出时序。实现
DESIGN.md的 fd/pipe 握手(option 2):每次 fork 形 respawn 造全新匿名管道,写 16 字节 nonce,spawn 前关写端,读端以 ≥100 的号交给子进程,配两个新 env 键__RUBASH_RESPAWN_PROOF_FD/__RUBASH_RESPAWN_PROOF;入口恰一次校验(fstat 须 FIFO、O_NONBLOCK 防挂、读恰 16 字节等于 nonce、再读须 EOF),成功后关闭;respawn_provenance_validated新增一臂(有效 proof + spawner 已死 → 开孤儿分支),旧两臂与__RUBASH_SPAWNER_PID戳不动。Refs #3300
本 PR 删除了什么
什么也没删除——纯新增机制 + 钉,无行为删除、无文件删除、无公开 API 删除。唯一的行为变化:被 subreaper 收养的孤儿 respawn 子进程现在采信来源(此前回退到重解析行号)。
腿况(车道本地)
tests/issue3300_subreaper_orphan_regressions.rs:5/5 head 绿;base 每轮 3–4/5 红(父子竞态调制;确定性 fail-first 见 REPORT 门探针)coproc { foooo\\<NL>bar; }GNU 2 / 我方 1) #3301 6 格 5/6(base 同数)RUSTFLAGS="-D warnings"构建 rc=0;cargo fmt干净;utf8 卫生 cleanbackground_firstbox 报 line 2、本地/GNU 报 line 1) #3300 形 GNU 恒 line 1,门探针 head 与 GNU 一致需队长裁
完整报告:
~/workspace/fix-3300/REPORT.md(Part II)