PHP 8.2 FPM Leaks processes on pcntl_fork
オープン
まだ誰も着手していません。
Extension: pcntl
Feature
Status: Needs Triage
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
OS: xenial
PHP tested: 8.2.7, 8.2.10
The following drupal 10 index.php:
<?php
/**
* @file
* The PHP page that serves all page requests on a Drupal installation.
*
* All Drupal code is released under the GNU General Public License.
* See COPYRIGHT.txt and LICENSE.txt files in the "core" directory.
*/
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
$autoloader = require_once 'autoload.php';
$kernel = new DrupalKernel('prod', $autoloader);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$pid = pcntl_fork();
if ( $pid !== 0 ) {
// we are the parent process
return;
}
sleep(10);
$kernel->terminate($request, $response);
After doing ~5 requests to the site, results in the following sub-processes to the FPM master:
root 15873 0.0 0.8 464188 17200 ? Ss 13:08 0:00 php-fpm: master process (/var/www/site-fpm/drush12test.prod/php-fpm-8.2.conf)
drush12+ 16518 0.7 1.4 466300 29860 ? S 13:11 0:00 \_ php-fpm: pool drush12test
drush12+ 16557 0.0 0.6 466300 13068 ? S 13:11 0:00 \_ php-fpm: pool drush12test
drush12+ 16559 0.0 0.6 466300 12640 ? S 13:11 0:00 \_ php-fpm: pool drush12test
drush12+ 16561 0.0 0.6 466300 12640 ? S 13:11 0:00 \_ php-fpm: pool drush12test
drush12+ 16563 0.0 0.6 466300 12640 ? S 13:11 0:00 \_ php-fpm: pool drush12test
But then after a few seconds, when it should clean them up, they will instead detach and linger around:
root 15873 0.0 0.8 464188 17188 ? Ss 13:08 0:00 php-fpm: master process (/var/www/site-fpm/drush12test.prod/php-fpm-8.2.conf)
drush12+ 16557 0.0 1.1 464252 23364 ? S 13:11 0:00 php-fpm: pool drush12test
drush12+ 16559 0.0 1.1 464252 23028 ? S 13:11 0:00 php-fpm: pool drush12test
drush12+ 16561 0.0 1.1 464252 23028 ? S 13:11 0:00 php-fpm: pool drush12test
drush12+ 16563 0.0 1.1 466300 23432 ? S 13:11 0:00 php-fpm: pool drush12test
The same doesn't happen with PHP 7.4. In that case the processes get cleaned up properly.
PHP Version
PHP 8.2.10
Operating System
Ubuntu 16.04
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された Drupal 10 の index.php 再現コードから始め、特に pcntl_fork() の呼び出しと PHP-FPM プロセスの動作を確認します。Ubuntu 16.04 上の PHP 8.2.10 で再現し、PHP 7.4 と比較します。sleep の後に fork されたプロセスが切り離されて FPM master 配下に残るのではなく、クリーンアップされれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100