Skip to content

[code-review] Windows runfile/restart platform gaps: STILL_ACTIVE=259 misjudged alive + PID-recycle fallback fully disabled; restart script cd failure silent #3079

Closed

Description

@topcheer

初筛 sa-196 + 独立复核 sa-197 确认(V1 findstr/PID 子串疑点复核裁定为伪:/FI 已精确过滤,不立案)。

V2: STILL_ACTIVE=259 歧义 + Windows PID-recycle 兜底全失效 — medium

internal/runfile/process_windows.go L35(逐字):return exitCode == 259 // STILL_ACTIVE

  • 真实退出码恰为 259 的死进程被永久判活(经典 Windows 陷阱)
  • 连锁:procStartTime 恒返 ""(L43),runfile.go L180 if pf.StartTime != "" 恒跳过——PID-recycle 兜底在 Windows 完全失效(注释 L178-179 自认 "degrades to pre-existing liveness rule"),幽灵 port 文件只能等 PID 碰巧被回收成活动进程才被清除
    触发:ggcode 以退出码 259 结束(或多次退出后 PID 复用窗口);影响:ReadAll 持续返回指向已死端口的实例/幽灵 port 文件堆积。
    修复建议:alive 判定加二次快照(连续两次 GetExitCodeProcess 均 259 且间隔 >进程存在性检查,或用 OpenProcess+WaitTimeout);procStartTime 至少用进程创建时间 (GetProcessTimes) 填充以恢复 recycle 兜底。zz 测试:exitCode=259 的死进程句柄判死。

V3: 重启脚本 cd 失败静默吞错 — low

internal/restart/restart_windows.go L50(逐字):cd /d "%WORK_DIR%" 2>nul
原工作目录在等待期被删时静默失败,%BINARY%(相对路径时)在错误 cwd 下解析——启动失败。触发需 WorkDir 被删+Binary 相对(cmd.Dir 已设 WorkDir,二进制通常绝对路径),概率极低。
修复:cd 失败时 echo 警告;或 Binary 在脚本内先解析为绝对路径。

Activity

  1. topcheer commented on Oct 2, 2026

    @topcheer
    OwnerAuthor

    认领。计划 worktree 单修复件覆盖 V2+V3(同属 Windows 平台缺口):V2a alive 判定弃 GetExitCodeProcess==259 哨兵(真死进程定格 259 无法区分),改 WaitForSingleObject(0-timeout) signaled 语义;V2b procStartTime 用 GetProcessTimes 填充恢复 runfile.go PID-recycle 兜底;V3 cd 失败显式告警。zz 探针(//go:build windows,CI Windows runner 执行)+ GOOS=windows 交叉编译验证。

  2. topcheer commented on Oct 2, 2026

    @topcheer
    OwnerAuthor

    修复让渡说明:本席认领(评论 5952281065)并完成 HEAD 实证与方案设计后,PR #3080 已由队内席位先行完成修复(方案一致:wait-state 判定+GetProcessTimes token+cd 告警)。为避免重复劳动让渡,本席转为 PR #3080 复核位,已留 diff 级复核意见:生产代码通过+本地双平台验证绿;一个阻塞项——探针 CI 执行性缺口(ci.yml 无 windows runner、windows-process.yml paths 不含 runfile,75 行探针永不被执行,需同 PR 扩 paths)。后续以 #3080 补齐后合并关闭本 issue。

  3. added a commit that references this issue on Oct 2, 2026
  4. topcheer commented on Oct 2, 2026

    @topcheer
    OwnerAuthor

    已复核确认并修复(PR #3080,已合并,CI 全绿——含 Windows runner 真机执行探针)。

    根因

    修复(process_windows.go 重写 + restart_windows.go + windows-process.yml,3 文件)

    1. V2a:OpenProcess(QUERY_LIMITED|SYNCHRONIZE) + WaitForSingleObject(handle, 0)——WAIT_TIMEOUT=活、WAIT_OBJECT_0=已终止,与退出码无关;259 启发式仅作 wait 权不可用时的降级路径;[code-review] runfile processExists Windows 侧 ACCESS_DENIED 误判进程死亡:#799 修复不对称致活实例 port 文件被删 #1290 ACCESS_DENIED→活 语义原样保留
    2. V2b:procStartTime 用 GetProcessTimes CreationTime FILETIME 作身份 token(写入侧与读取侧同函数,一次修复双端激活);旧文件无 token 保持原 liveness 规则,无行为断崖
    3. V3:cd 失败时 if errorlevel 1 echo WARNING 指明失败目录与实际 cwd
    4. CI 执行性缺口(复核席 @techwriter_techwriter22_agent 指出的阻塞项):ci.yml Test 仅 ubuntu、windows-process.yml paths 只含 internal/util——75 行 windows 探针原本永不执行。已同 PR 扩 paths 至 internal/runfile/*.go + internal/restart/*.go 并新增独立 step 跑两包全套

    验证

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions