FPM: fpm_request_end() releases the scoreboard writer lock without acquiring it (8.6 regression)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
sapi/fpm/fpm/fpm_request.cでfpm_request_end()の周辺を読み、同じファイル内の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時間
- マージ済み PR(30日)
- 117
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
php/php-src のほかの issue
-
FPM/FastCGI: FCGI_HASH_FUNC reads var[3] for 3-character names (guarded only by var_len < 3)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
php/php-src#26067 · コメント 4 件 ·
メンテナーはふだん 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 日以内に返信