FPM: fpm_request_end() releases the scoreboard writer lock without acquiring it (8.6 regression)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
阅读 sapi/fpm/fpm/fpm_request.c 中 fpm_request_end() 附近的代码,并将其中对 scoreboard 的调用与同一文件中的 begin/commit 配对进行比较。检查 sapi/fpm/fpm/fpm_scoreboard.c 中的锁行为;issue 指出了缺失的调用,以及将其安全地放在 fpm_scoreboard_proc_release(proc) 之后的位置。完成标准是:request end 在提交前获取写锁,且 proc == NULL 返回路径保持不变。
由索引模型根据 Issue 内容生成。
描述
Description
In PHP 8.6 the FPM scoreboard write path was split into two halves:
fpm_scoreboard_update_begin()acquiresscoreboard->writer_activeand waits forreader_count == 0.fpm_scoreboard_update_commit()writes the shared counters and then releaseswriter_active(fpm_unlock(scoreboard->writer_active);,sapi/fpm/fpm/fpm_scoreboard.c:218).
Every writer pairs the two calls — e.g. in sapi/fpm/fpm/fpm_request.c at lines 45/58 and 77/102 — except fpm_request_end(), which calls only commit:
sapi/fpm/fpm/fpm_request.c:205
fpm_scoreboard_update_commit(-1, -1, -1, -1, -1, -1, -1, proc->memory, FPM_SCOREBOARD_ACTION_SET, NULL);
with no preceding fpm_scoreboard_update_begin().
Because commit ends by releasing writer_active, at the end of every request fpm_request_end():
- releases a writer lock it never acquired — if another process legitimately holds
writer_activeat that moment, this clears it, letting a second writer and readers run concurrently with it; and - updates the shared counters (
memory_peak,active_max, ...) without first ensuringreader_count == 0, so a concurrent?fullstatus reader (fpm_scoreboard_copy) can read a torn scoreboard.
This is a correctness regression from the 8.6 begin/commit split (8.3 has no such split — it uses a single fpm_scoreboard_update()), not a memory-safety issue: the scoreboard is a fixed shared struct of scalars, so the consequences are limited to garbled status/metrics and a possible writer-lock imbalance.
Suggested fix
Add the matching fpm_scoreboard_update_begin(NULL) immediately before the commit in fpm_request_end() (after fpm_scoreboard_proc_release(proc)), so the writer lock is held across the shared-counter update. Placing begin right before commit (rather than at function entry, as the other sites do) avoids leaking the writer lock on the proc == NULL early-return path. PR to follow.
PHP Version
PHP-8.6 branch at 47abe238897 (PHP 8.6.2-dev (fpm-fcgi), NTS DEBUG).
Operating System
Linux
- 主要语言
- C
- 星标
- 41.9k
- 派生
- 8.5k
- 平均合并
- 2 天 16 小时
- 30 天内合并 PR
- 117
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
php/php-src 的其他 Issue
-
FPM/FastCGI: FCGI_HASH_FUNC reads var[3] for 3-character names (guarded only by var_len < 3)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
Bug Status: Verified
难度 1/5 1 小时以内 新手友好度 74/100
维护者通常 1 天内回复
-
getimagesize(): WebP VP8 dimensions are accepted with an invalid start code可能已有人在做 @lazerg 于 5 天前认领。 未关闭Bug Status: Needs Triage
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
相似的 Issue
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBuffer未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
needs triage
难度 2/5 1-3 小时 新手友好度 72/100
389ds/389-ds-base#8251 ·
维护者通常 1 天内回复
-
bug data-types
难度 2/5 1-3 小时 新手友好度 76/100
ClickHouse/clickhouse-cpp#645 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
ROCm/hrx-system#3628 ·
维护者通常 1 天内回复