Skip to content

fix(starry-ptrace): deliver kill before releasing event stop - #1799

Closed
ZR233 wants to merge 157 commits into
codex/refactor-ax-task-from-1596from
codex/fix-pr1775-ptrace-gdb
Closed

fix(starry-ptrace): deliver kill before releasing event stop#1799
ZR233 wants to merge 157 commits into
codex/refactor-ax-task-from-1596from
codex/fix-pr1775-ptrace-gdb

Conversation

@ZR233

@ZR233 ZR233 commented Jul 31, 2026

Copy link
Copy Markdown
Member

问题

PTRACE_KILL 曾在发布 SIGKILL 前清除 tracee 的 ptrace event stop。这样信号发送路径会失去被阻塞线程的 TID,tracee 可能在致命信号可见前恢复并执行下一条用户态指令。

该顺序修复后,RISC-V CI 仍暴露了一个相邻竞态:tracee 已发布 ptrace stop、但尚未进入可中断等待时,tracer 发送的 SIGKILL 会被等待函数当作建立 stop 时遗留的中断确认掉。test-proc-status-tracerpid 因而停在该等待点,最终使 Test starry riscv64 qemu 在 1800 秒后超时。

修改

  • 保持 ptrace event stop 到 SIGKILL 已选择并中断对应 tracee 之后,避免恢复用户态先于致命信号发布。
  • 为 ptrace-stop 等待传入 stop 可见前的中断快照,只确认该快照覆盖的旧中断,保留随后发布的 kill 唤醒。
  • 在注册等待 waker 前后检查进程级待处理 SIGKILL;即使唤醒已到达,也会释放 ptrace stop 并在下一个信号安全点终止 tracee。
  • 删除 alarm worker 的文件末尾空白,并移除 IRQ waiter 测试中对无 Drop token 的无效 mem::forget;测试仍通过结束 token 借用后析构 attached registration 覆盖该断言路径。

这一改动影响的是已被 ptrace 截获的信号 stop 与 SIGKILL 的状态转换,以及对应的测试和 diff hygiene,不增加新的用户态接口。

验证

  • 修复前:timeout --foreground 180s env TGOS_IMAGE_LOCAL_STORAGE=<rootfs> cargo xtask starry test qemu --arch riscv64 -c qemu/test-proc-status-tracerpid 停在 STARRY_SYSTEM_TEST_BEGIN,以退出码 124 超时。
  • 修复后:同一 RISC-V QEMU case 在 28.84 秒通过;测试内 64 次跨 CPU ptrace-stop/SIGKILL 轮次均完成。
  • review 修复前:cargo clippy -p ax-task --tests -- -D warningsclippy::forget_non_drop 失败。
  • cargo test -p ax-task --lib dropping_an_attached_registration_is_rejected 通过。
  • cargo clippy -p ax-task --tests -- -D warnings 通过。
  • cargo xtask clippy --package ax-task(1/1 检查通过)。
  • cargo fmt --all --check
  • git diff --check <PR-base>...HEAD

本 PR 的 base 是 #1775 当前分支。

ZR233 added 30 commits July 31, 2026 14:25
@ZR233
ZR233 marked this pull request as ready for review July 31, 2026 07:59
@ZR233
ZR233 force-pushed the codex/refactor-ax-task-from-1596 branch from 8998618 to 6282d90 Compare July 31, 2026 08:25

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本 PR 将原有任务/调度实现拆分为新的 ax-task 共享运行时,并同步迁移 StarryOS 的任务、ptrace、信号、计时器及相关测试;其中 HEAD 的 ptrace 修复意在确保 SIGKILL 在解除 event-stop 前投递。该变更跨越共享调度 API 和 Starry syscall/Linux ABI,非隔离修改;已按 code-quality.mdfeature-development.mdstarry/syscall.md 审查。新增设计材料位于 book/design/,但当前有以下阻塞项。

本地验证:python3 /tmp/review_pr_helper.py testprepare-reviewcargo fmt --checkcargo test -p ax-task --tests 均通过;cargo clippy -p ax-task --tests -- -D warnings 失败(见行内评论);git diff --check origin/dev...HEAD 失败(见行内评论)。由于这些基础质量门禁已失败,未继续运行成本很高的 Starry QEMU 全量场景,当前不能以新增测试或现有 CI 作为合并依据。

CI:当前 head 的组织内 CI workflow 结论为 failure;检查汇总还包含取消/跳过的矩阵项,不能视为通过。本地 clippy 已确定复现 ax-task 新增测试中的失败,和本 PR 直接相关。

既有 review / issue 评论均为空,无需处理历史线程。已检查基础分支中相邻 ptrace 实现及以 ax-taskptracescheduler 为关键词的开放 PR 候选;本次大规模调度迁移与当前 base 的旧实现并不重复,但影响面很大,修复下述门禁后仍应由任务/Starry 领域维护者复核完整运行时与 QEMU 覆盖。

清单审计:约束、head、差异、依赖 patch(未发现 [patch.crates-io])、设计材料、历史讨论、CI 与聚焦 ax-task 测试均已核对;阻塞项为下列两处。没有新增或直接声明的独立 app 工作流需要在本轮作为可批准依据运行。

Powered by gpt-5.6-terra

)
.unwrap_or_else(|error| panic!("failed to spawn alarm task: {error}"));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

【阻塞|diff hygiene】git diff --check origin/dev...HEAD 在此处报告 new blank line at EOF。这会使提交检查仍然报错;请删除第 59 行的多余空行,并重新运行该检查确认补丁无空白错误。

let registration = TestRegistration::new();
let token = expect_registered(cell.register(registration.registration()));

core::mem::forget(token);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

【阻塞|clippy】cargo clippy -p ax-task --tests -- -D warnings 在这里因 clippy::forget_non_drop 失败:IrqWaitToken 不实现 Drop,因此 core::mem::forget(token) 与正常离开作用域等价。请删除该无效调用(或改为测试真正具有 Drop 语义的对象),并重新通过该 clippy 命令。

@mai-team-app mai-team-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本 PR 将任务/调度实现迁移为共享的 ax-task 运行时,并同步调整 StarryOS 的 task、计时器、ptrace/SIGKILL 路径及回归覆盖。它会影响共享调度契约和 Starry 用户可见的进程/信号语义,不是隔离改动;本轮已按 code-quality.mdfeature-development.mdstarry/syscall.md 审查。新增设计材料在 book/design/,但当前仍有两项确定的质量门禁阻塞合入。

验证:python3 /tmp/review_pr_helper.py testprepare-reviewcargo fmt --check 均通过。git diff --check origin/dev...HEADworker.rs:59 失败;实际执行 cargo clippy -p ax-task --tests -- -D warningsirq_wait_tests.rs:67clippy::forget_non_drop 失败。按本次指令,当前 head 的组织内 CI Route branch push CI 已成功,因此未重复成本较高的 QEMU 全量运行;但 CI 成功不能替代上述已复现的本地质量门禁。

现有评审:此前 review 的两个 actionable 评论在旧 head 上提出;当前 head 已修复其直接问题(worker EOF 空白行与 forget_non_drop 仍存在,故本 review 重新报告)。没有 issue 评论。开放 PR 检索发现 #1801 与 ptrace/SIGKILL 修复部分重叠;读取其 patch 后确认其不包含本 PR 的 PTRACE_KILL 顺序与 interruption snapshot 补丁,因而不是本 PR 的重复阻塞,但维护者合并时应避免再叠加同类链路。

依赖审查未发现 [patch.crates-io]test-proc-status-tracerpid 已由现有 system CMake 结构接入;本轮未发现新的独立 app 工作流。清单已完成:约束、head、基线模式、主要 ax-task/ptrace 同步路径、测试接入、CI、历史评论和开放 PR 重叠均已核验。阻塞项如下;修复并重新通过对应命令后,仍建议由任务与 Starry 领域维护者复核这次大规模运行时迁移的完整 QEMU 覆盖。

Powered by gpt-5.6-terra

)
.unwrap_or_else(|error| panic!("failed to spawn alarm task: {error}"));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

【阻塞|diff hygiene】此处的文件末尾新增了空白行,git diff --check origin/dev...HEAD 在当前 head 报告 new blank line at EOF。请删除该空白行并重新执行该检查,确保补丁不存在空白错误。

let registration = TestRegistration::new();
let token = expect_registered(cell.register(registration.registration()));

core::mem::forget(token);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

【阻塞|clippy】IrqWaitToken 不实现 Drop,所以这里的 core::mem::forget(token) 与正常离开作用域等价,并会触发 clippy::forget_non_drop。实际执行 cargo clippy -p ax-task --tests -- -D warnings 已在此处失败。请删除该无效调用(普通离开作用域即可保持该测试的 attached-registration 状态),或改为测试真正具有 Drop 语义的对象,然后重新通过该 clippy 门禁。

@ZR233 ZR233 closed this Jul 31, 2026
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