Repository navigation
fix(executor): net bind saves displaced fd via kernel dup (Refs #3726) - #3740
Conversation
bind_simple_command_net_inputs' in-process net bind saved the displaced fd-table entry as a bare Rc clone; the bind's open_input / open_output retired that descriptor (retire_read_arm / retire_write_arm, rubash#3213), so restore_simple_command_net_inputs re-inserted a retired entry and the next read saw EBADF (same hazard as #3706, on the network-redirect face). The undo save is now a kernel dup via FdTable::saved_entry / FdEntry::dup_file_endpoints (GNU redir.c:965/1082/1144 fcntl (fd, F_DUPFD, SHELL_FD_BASE); execute_cmd.c:854 RX_UNDOABLE); a dup failure fails the whole redirect list like a refused connect (diagnostic + status 1, body never runs; binds already made are unwound, execute_cmd.c:855). NOTE: the fd_table.rs hunk (FileFd::duplicate / FdEntry::dup_file_endpoints / FdTable::saved_entry) is byte-identical to draft PR #3723's; whichever merges second drops the duplicate. UNVERIFIED-BY-CAPTAIN: no build slot existed in this lane (see REPORT); pin fail-first / head-green / lib / -D warnings legs OWED.
|
【WIN-AGENT-AUDIT】PR #3740 第1轮 — 建议:FAIL 机制核查:
腿(逐项给数字与名字):
F 点:
未跑/VOID 的腿:无。 |
|
【WIN-AGENT-AUDIT】PR #3740 第2轮 — 建议:PASS 机制核查:
腿(逐项数字):
F 点:无(上轮唯一 F1 已按 (a) 处置) 续作记录:
未跑/VOID 的腿:新 head CI 待跑完核对;其余无。 |
|
【WIN-AGENT-AUDIT】PR #3740 第3轮 — 建议:PENDING(产品面已被 master 覆盖,合并需队长裁定;非代码缺陷) 本轮新发现(决定性):本 PR 的产品修复已被 master 上的 #3728 落地,剩余价值仅钉文件。 证据:
CI:head a383836 无任何 check-run(gh api check-runs 为空、gh run list --commit 无记录)——push(2026-11-16T13:49Z)未触发 Actions,与 #3724 同批 push(13:56Z)却正常触发形成对照,疑似该次 push 事件丢失。腿不补也不影响本判词:产品面已被覆盖的结论不依赖 CI。 建议处置(供队长裁定,三选一):
腿:钉自跑(head 第2轮 7/7 Win + 8/8 Linux;本轮 master 侧 7/7 Win 复验);fail-first(第1轮 base e3a7b7b Linux 7f/1p, 续作记录:本轮为验证+裁定请求轮,未动代码、未解冲突。 |
|
【WIN-AGENT-AUDIT】PR #3740 第4轮 — 建议:PENDING(已按第3轮选项(a)降级为纯钉 PR;合并与否仍需队长裁定) 本轮处置:执行第3轮给出的选项 (a)——merge origin/master 解冲突时产品文件(builtin_redirects.rs、fd_table.rs)全取 master 侧,仅保留 机制核查:
腿(逐项数字):
F 点:无(产品面缺陷已由 #3728 修复,本 PR 无产品代码可判)。 队长裁定项(维持第3轮三选一,本轮已执行 a 的机械部分):
续作记录:
未跑/VOID 的腿:无。 |
|
【WIN-AGENT-AUDIT】PR #3740 第5轮(o2)— 判词:FAIL(纯钉非判别,不合入;产品面已由 master 覆盖) head: 7ef7850 base(merge-base): 969230b 文件: 1 个 +319(仅 判别力复核(本轮的裁决腿):
产品面(WSL Linux 原生 master 复核,非 Windows 仿真):
#3726 处置:issue 描述的全部形状(read bind 的 fd0/3/8、多 numbered、 未跑/VOID:Windows 判腿(fd 族 Windows 面为 |
|
【o2 判词】PASS(纯钉,fd 族 WSL Linux 原生复核)。head 本轮 腿(全部 WSL Linux 原生,非 Windows 仿真 fd table):
CI 归因(本 PR 无 src 改动): 关联 #3726 已 CLOSED(产品面在 master),本钉不关单。 |
fix(executor): net bind saves displaced fd via kernel dup (Refs #3726)
根因
bind_simple_command_net_inputs(rubash#2124 的 in-process net bind,builtin/function 路由)的 undo save 只做了被顶掉的 fd-table entry 的裸Rcclone;随后bind_net_input_fd的open_input/open_output把 /dev/tcp|udp 载体绑到该 fd 上,retire_read_arm/retire_write_arm(rubash#3213)把被顶掉的描述符 retire 掉;dispatch 结束后restore_simple_command_net_inputs又把 retired entry 插回表里——下一次read见 EBADF,下一次 spawn 的 pin pass 会把回收了该内核号的描述符 dup2 到该 fd 上。与 #3706 同一 hazard,发生在网络重定向面上。修法(按机制,不打地鼠)
GNU 的 undoable redirect 在 bind 之前用内核 dup 保存被顶掉的描述符:
fcntl (fd, F_DUPFD, SHELL_FD_BASE)(redir.c:965 input、:1082 duplicating、:1144 move;SHELL_FD_BASE=10,redir.c:86),add_undo_redirect记录,undo_redirections再 dup 回来;compound 组跑do_redirections (..., RX_ACTIVE|RX_UNDOABLE)(execute_cmd.c:854)。src/executor/fd_table.rs(+107):FileFd::duplicate(unixF_DUPFD_CLOEXEC/ Windowsduplicate_handle)、FdEntry::dup_file_endpoints(File/Coproc 端点逐个 dup,<>双臂共享一个 dup 以保持共享语义)、FdTable::saved_entry。本 hunk 与草稿 PR fix(executor): restore fd N after group redirect (Refs #3706) #3723 的 fd_table.rs hunk 逐字节相同;两支无论谁先合入,后合的一方 rebase 时丢掉重复 hunk。src/executor/builtin_redirects.rs(+38/−4):bind_net_input_fd改为经saved_entry快照并 fallible(Result<(), std::io::Error>);dup 失败时按 GNUREDIRECTION_ERROR处理——已绑的按undo_partial_redirects(execute_cmd.c:855) unwind,然后像 refused connect 一样报诊断 + status 1、body 不跑。调用方只有bind_simple_command_net_inputs(codegraph + rg 双核),command_dispatch.rs不用动。tests/issue3726_net_bind_fd_restore.rs(新,8 cells):fd 8 原语、fd 0 winner、fd 3、<>双臂存活、双 numbered bind、Linux-only /proc 面、plain-builtin 控制、<>close 共享 guard;listener harness 沿用 [bug] 内建命令的 /dev/tcp 胜出输入重定向在 Linux 上从不连接且静默无诊断 #2124 形状。本 PR 删除了什么
无。只改了 undo save 的快照方式(裸 clone → 内核 dup)与
bind_net_input_fd的签名(()→Result<(), std::io::Error>);retire_*机制、restore_simple_command_net_inputs、dispatch_net_bound_fds均未动;未碰src/lexer/continuation.rs,未改docs/api-ledger.md(无新公开面),未引入 trust/签名/加载期校验机制。验证
UNVERIFIED-BY-CAPTAIN:本车道无任何构建槽(Simular box 钱包空 hibernated、X299 与老服务器同断、本 VM 禁本地构建),以下腿全部 OWED,由队长/Win-agent 在路线恢复后补跑,见
~/workspace/fix-3726/REPORT.md§7:e3a7b7b3):cells 1–6 红,cells 7–8 绿。--bin rubash)。RUSTFLAGS="-D warnings" cargo check --locked --lib --bins。cargo fmt --check(本车道已用rustfmt --check过 3 个改动文件:clean;hygiene 两脚本 clean)。cargo check --tests(改动含#[cfg(unix)]fcntl 分支与#[cfg(windows)]duplicate 分支)。守卫(fresh 扫描,PR 开时)
同文件 open PR 仅 #3565(builtin_redirects.rs hunks :266、:714/:748/:801)与 #3685(fd_table.rs hunk @@-43)、#3723(fd_table.rs 相同 hunk,见上)。在飞车道文件面无重叠。