Skip to content

test(issue977): harden bind -x interrupted pin settle window (Refs #3289) - #3469

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3289-issue977-pin-settle-window
Nov 15, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3289-issue977-pin-settle-window

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

根因

钉 tests/issue977_bind_x_interrupted.rs 的 drive() 在投递 SIGINT 前只盲目 sleep(500ms) 等 widget 进入前台等待。box 负载下 runner 线程在建 started.txt 与 spawn 子进程之间可被调度延迟超过 500ms,信号落在窗口内则从未被登记(trap count 0、无 unwind)——负载形 flake,非产品缺陷(PR #3273 合入轮已裁定)。前台等待本身是 10ms 切片循环(src/executor/external_inner.rs 的 wait_fg_child_draining / wait_fg_child_sliced,每片调 observe_signals_while_blocked)。

改动(只动测试面)

  • 新增 foreground_sleep_child_running():/proc 扫描本进程的 sleep 子进程;无 /proc 时恒 false,退化为固定 settle。
  • 新增 wait_for_foreground_wait():2s 轮询(25ms 步进)+ 命中后 250ms 入等待 grace,超时照常投递;无 /proc 时退化为 2s 固定 settle(旧 500ms 的 4 倍)。
  • drive() 内盲目 sleep(500ms) 改为调用 wait_for_foreground_wait()。
  • trapped / ignored 两单元外部睡眠 2s → 4s,保证投递在轮询最坏情况(2s + 250ms)下仍落在睡眠中段;ignored 单元 elapsed 断言 1800ms → 3800ms(4s 睡眠下旧阈值会在睡眠被截到 ~2s 时仍放行)。
  • 钉契约不变:untrapped SIGINT 仍置 interrupted、status 130、post-sleep 命令不跑、6s 睡眠不被截短。

GNU 锚点

沿用钉头既有注释:bashline.c:4603/4688、jobs.c:3316(ADDINTERRUPT)、eval.c parse_and_execute DISCARD 臂。

本 PR 删除了什么

无。只改测试钉:删除 drive() 内一行盲目 sleep(500ms),由轮询等待替代;无产品代码、无公开面、无文档改动。

验证状态

UNVERIFIED-BY-CAPTAIN。本轮无可用构建槽(本地写墙、box 盘满、老服务器 ssh 超时、X299 未直连),以下腿留复核轮:旧钉负载下复现 flake、新钉多遍复跑、全量 lib 与 base 逐数对齐、RUSTFLAGS="-D warnings" cargo check --locked --lib --bins。已跑:rustfmt --check(本文件)、marker-lint、UTF-8 边界 hygiene,全绿。

)

Replace the blind 500ms settle in drive() with a poll-with-timeout
for the widget's foreground wait: foreground_sleep_child_running()
(/proc scan for this process's sleep child) + wait_for_foreground_wait()
(2s poll, 250ms arming grace, deliver regardless on timeout; degrades
to a 2s fixed settle without /proc).

Root cause: under box load the runner thread can sit unscheduled for
longer than 500ms between creating started.txt and spawning the child,
and a SIGINT delivered in that window is never registered (trap count
0, no unwind) -- a load-shaped flake, not a product defect (adjudicated
in the PR #3273 merge round). The foreground wait is a 10ms-slice loop
(wait_fg_child_draining / wait_fg_child_sliced in external_inner.rs,
each slice calling observe_signals_while_blocked); delivering only
once the child exists closes the whole window.

The trapped/ignored cells' external sleep goes 2s -> 4s so the
delivery still lands mid-sleep at the poll's worst case (2s + 250ms);
the ignored cell's elapsed guard tightens 1800ms -> 3800ms to match.
The builtin-sleep cell already sleeps 4s.

GNU anchors (unchanged, per the pin header): bashline.c:4603/4688,
jobs.c:3316 (ADDINTERRUPT), eval.c parse_and_execute DISCARD arm.

UNVERIFIED-BY-CAPTAIN: no build slot available this round (local
write wall, box disk full, old server ssh down, X299 not yet
reachable) -- repeat runs, full-lib alignment and -D warnings check
are owed to the review round.
@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
PR #3469 第1轮 — 建议:PASS
head: 4026013 base(merge-base): e50cea9 文件: 1 个 +85/-7
关联 issue: #3289(状态:open,我核过的时间:2026-11-15 08:45 CST)

机制核查:

  • 纯测试腿修复:把钉里固定的 500ms SIGINT 投递前 settle 换成 /proc 轮询「本进程是否存在名为 sleep 的前台子进程」(2s 上限 + 250ms arming grace),无 /proc 平台(Windows/macOS)退化为 2s 固定等待;被测语义(untrapped SIGINT → 丢弃行;trapped → trap 恰好一次;ignored → 完全不切断 sleep)断言逐字未改,GNU 锚仍是 bashline.c:4603/4688、jobs.c:3316、eval.c DISCARD 臂。sleep 2s→4s 与 elapsed ≥3.8s 配套,保证退化路径下投递仍落在 sleep 中点。
  • diff 无无关改动;无 trust/签名类机制;未碰 continuation.rs。

腿(逐项给数字与名字):

F 点:无

未跑/VOID 的腿:

  • Windows 钉自跑 VOID:#![cfg(unix)],0 tests;以 Linux 5/5 为准
  • 假绿检查:通过(断言未放松,仅改投递时机)

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-BATCH-SUMMARY】
Wave 3 后半钉批(重分工后我负责的前段 7 个)审核完毕,逐 PR 报告评论已发各 PR 下。判词一览:

PR 建议 关键证据
#3469 建议 PASS 纯钉加固(/proc 轮询替代 500ms 盲等);Linux head 5/5 绿;断言未放松
#3471 建议 FAIL head @Windows dirs 3 格红:期望助手产出 D:\...,引擎打 /d/...;GNU 语义方向对,钉拼写面缺陷(F1)
#3472 建议 PASS lib 双边差集 ∅;issue2875 有/无 bin 两态实测符合设计;CI 红仅基线
#3473 建议 FAIL Linux head 5/7:exec {v}>&- 与 varredir_close 关闭路径不摘物化号,/proc/$$/fd 残留悬空项(F1)
#3474 建议 FAIL head 5/6:pipeline 首段 external+funsub-exit heredoc 仍红,GNU 应 status=0 pipe=42 0 续行(F1);fail-first 3 格 base 红有效
#3475 建议 FAIL Linux head 18/20:coproc >x ! echo hi 的 ! 未按词(产品 F1);brace 守卫格断言旧残差 { 而 GNU/产品现报 }(钉 F2);Windows 另有 heredoc Broken pipe 平台残差(F3 注明)
#3476 建议 PASS Linux head 2/2 绿;fail-first base 1 红有效;lib 差集 ∅;GNU hash 存 as-found 拼写逐字核过

共线事实:7 个 head 的 Windows lib 失败集均为 {issue2084_session_end_restores_host_process_state}(本机既有基线,非任何 PR 账);各 head CI 红名均仅基线 issue2875;全部 fmt 逐文件 clean、-D warnings 0 警告、diff 无 carrier/PUA 字节。

阻塞/移交项:

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 15, 2026 02:09
@caomengxuan666
caomengxuan666 merged commit f748652 into master Nov 15, 2026
8 of 11 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