fix(starry-ptrace): deliver kill before releasing event stop - #1799
fix(starry-ptrace): deliver kill before releasing event stop#1799ZR233 wants to merge 157 commits into
Conversation
8998618 to
6282d90
Compare
There was a problem hiding this comment.
本 PR 将原有任务/调度实现拆分为新的 ax-task 共享运行时,并同步迁移 StarryOS 的任务、ptrace、信号、计时器及相关测试;其中 HEAD 的 ptrace 修复意在确保 SIGKILL 在解除 event-stop 前投递。该变更跨越共享调度 API 和 Starry syscall/Linux ABI,非隔离修改;已按 code-quality.md、feature-development.md 和 starry/syscall.md 审查。新增设计材料位于 book/design/,但当前有以下阻塞项。
本地验证:python3 /tmp/review_pr_helper.py test、prepare-review、cargo fmt --check、cargo 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-task、ptrace、scheduler 为关键词的开放 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}")); | ||
| } | ||
|
|
There was a problem hiding this comment.
【阻塞|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); |
There was a problem hiding this comment.
【阻塞|clippy】cargo clippy -p ax-task --tests -- -D warnings 在这里因 clippy::forget_non_drop 失败:IrqWaitToken 不实现 Drop,因此 core::mem::forget(token) 与正常离开作用域等价。请删除该无效调用(或改为测试真正具有 Drop 语义的对象),并重新通过该 clippy 命令。
There was a problem hiding this comment.
本 PR 将任务/调度实现迁移为共享的 ax-task 运行时,并同步调整 StarryOS 的 task、计时器、ptrace/SIGKILL 路径及回归覆盖。它会影响共享调度契约和 Starry 用户可见的进程/信号语义,不是隔离改动;本轮已按 code-quality.md、feature-development.md 与 starry/syscall.md 审查。新增设计材料在 book/design/,但当前仍有两项确定的质量门禁阻塞合入。
验证:python3 /tmp/review_pr_helper.py test、prepare-review、cargo fmt --check 均通过。git diff --check origin/dev...HEAD 在 worker.rs:59 失败;实际执行 cargo clippy -p ax-task --tests -- -D warnings 在 irq_wait_tests.rs:67 因 clippy::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}")); | ||
| } | ||
|
|
There was a problem hiding this comment.
【阻塞|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); |
There was a problem hiding this comment.
【阻塞|clippy】IrqWaitToken 不实现 Drop,所以这里的 core::mem::forget(token) 与正常离开作用域等价,并会触发 clippy::forget_non_drop。实际执行 cargo clippy -p ax-task --tests -- -D warnings 已在此处失败。请删除该无效调用(普通离开作用域即可保持该测试的 attached-registration 状态),或改为测试真正具有 Drop 语义的对象,然后重新通过该 clippy 门禁。
问题
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 秒后超时。修改
SIGKILL已选择并中断对应 tracee 之后,避免恢复用户态先于致命信号发布。SIGKILL;即使唤醒已到达,也会释放 ptrace stop 并在下一个信号安全点终止 tracee。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 超时。cargo clippy -p ax-task --tests -- -D warnings因clippy::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 --checkgit diff --check <PR-base>...HEAD本 PR 的 base 是 #1775 当前分支。