Skip to content

fix: Windows 上信号名退化成 SIG11 - #117

Merged
crazywhalecc merged 1 commit into
masterfrom
fix/worker-crash-signal-fallback
Oct 25, 2026
Merged

crazywhalecc merged 1 commit into
masterfrom
fix/worker-crash-signal-fallback

Conversation

@crazywhalecc

Copy link
Copy Markdown
Member

问题

#116 合并后 master 的 Test workflow 变红,只有 windows-latest 全挂(8.1/8.2/8.3/8.4),Linux/macOS 全绿:

✘ Signal names and hints
✘ Writes log file with signal detail
Failed asserting that '[WORKER_ERROR] ... signal=11(SIG11) ...'
Tests: 115, Assertions: 427, Failures: 2

原因:上一版把信号表改成「只按 pcntl 常量解析」,而 Windows 没有 pcntl,defined('SIGSEGV') 全为 false → 映射表为空 → 退化成 SIG11。

修复

改成「跨平台兜底表 + 平台常量覆盖」:

  • 兜底表只收 Linux 与 macOS 编号一致 的信号:1/2/3/4/5/6/8/9/11/13/14/15/24/25,Windows 上靠它仍能给出 SIGSEGV/SIGKILL 这类可读名字;
  • SIGBUS / SIGUSR1 / SIGUSR2 不进兜底表(各平台编号不同:Linux SIGBUS=7、SIGUSR1=10;macOS SIGBUS=10、SIGUSR1=30),继续由 defined() 常量按当前平台覆盖。

这样既修掉 Windows,又保留上一轮「Linux 上不再把 SIGUSR1 误报成总线错误」的效果。

验证

  • 本地 phpunit --filter WorkerCrashGuardTest:4 tests / 53 assertions OK
  • 关键验证点是本 PR 的 windows-latest job(本地无法模拟没有 pcntl 的环境:Homebrew PHP 是 --enable-pcntl 编译进去的)

上一版把信号表改成「只按 pcntl 常量解析」,但 Windows 没有 pcntl,
defined('SIGSEGV') 等全为 false,映射表为空,日志里变成 signal=11(SIG11),
WorkerCrashGuardTest 的两条用例在 windows-latest 上失败(master 变红)。

改为「跨平台兜底表 + 平台常量覆盖」:
- 兜底表只收 Linux 与 macOS 编号一致的信号(1/2/3/4/5/6/8/9/11/13/14/15/24/25),
  Windows 上靠它仍能给出 SIGSEGV / SIGKILL 等可读名字;
- 不再把 SIGBUS / SIGUSR1 / SIGUSR2 放进兜底表(各平台编号不同),
  继续由 defined() 常量按当前平台覆盖。
@crazywhalecc
crazywhalecc merged commit 7827ddf into master Oct 25, 2026
21 checks passed
@crazywhalecc
crazywhalecc deleted the fix/worker-crash-signal-fallback branch October 25, 2026 03:12
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