php_admin_[flag|value] falsely applies config changes
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
Quick explanation of the problem.
When using strace I noticed stat system calls for the files already in opcache, even though opcache.enable_file_override is set to 1. The system calls are triggered by is_file() being invoked from PHP.
php_admin_flag[opcache.enable_file_override] = On is set in the pool config /etc/php/8.1/fpm/pool.d/www.conf
var_dump(opcache_get_configuration()) when being invoked through an fpm process says:
["opcache.enable_file_override"]=>
| bool(true)
phpinfo() says the same, enable_file_override is On.
I suspect the actual value of the flag is Off.
How to reproduce the issue.
- Ensure that opcache is enabled and enable_file_override is disabled (disabled by default). Also, set in the ini file:
opcache.file_update_protection=0
opcache.validate_permission=0
opcache.validate_timestamps=0
- Apply the fpm pool settings for simplicity of testing:
pm = static
pm.max_children = 1
- Add three test scripts to the document root of apache server:
test_opcache.php
<?php
echo "test begin\n";
$file1 = 'include_1.php';
$file2 = 'include_2.php';
if (is_file($file1)) {
include $file1;
}
if (is_file($file2)) {
include $file2;
}
echo "test end\n";
plus two more scripts in the same directory:
include_1.php
<?php
echo __FILE__ . "\n";
include_2.php
<?php
echo __FILE__ . "\n";
- Invoke the test_opcache.php to warm up the opcache via curl request or browser.
- Attach to the child fpm process using
strace -p <pid> -e newfstatat,fstat,stat. - Invoke the test_opcache.php again. Expected strace output:
newfstatat(AT_FDCWD, "/", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
newfstatat(AT_FDCWD, "include_1.php", {st_mode=S_IFREG|0644, st_size=29, ...}, 0) = 0
newfstatat(AT_FDCWD, "include_2.php", {st_mode=S_IFREG|0644, st_size=29, ...}, 0) = 0
- Set
php_admin_flag[opcache.enable_file_override] = Onin the pool config and restart apache and fpm. - Check if the config value is changed via var_dump(opcache_get_configuration()).
- Repeat steps 4, 5, and 6. The strace output won't change.
- Set opcache.enable_file_override=1 in the php.ini file and repeat steps 4, 5, and 6. The output will change to
newfstatat(AT_FDCWD, "/", {st_mode=S_IFDIR|0755, st_size=4096, ...}, 0) = 0
Conclusion
The opcache.enable_file_override flag works only when it's set in the ini file.
The worst thing is that setting the flag in the pool config gives a false positive result in opcache_get_configuration() and phpinfo(), which might be very misleading.
PHP Version
PHP 8.1.13
Operating System
Ubuntu 18.04
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
/etc/php/8.1/fpm/pool.d/www.conf の php_admin_flag[opcache.enable_file_override] がどのように適用されるかを追跡することから始め、php.ini の opcache.enable_file_override と比較します。opcache_get_configuration()、phpinfo()、および strace の再現を使用して、pool 設定が有効な場合に報告される値と file-stat の動作が一致することを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c
- 領域
- backend, performance
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100