php / php/php-src

opcache doesn't list all files with the same path when using chroot (opcache_get_status())

オープン
#18,772 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Bug Extension: opcache Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

The following code:

<?php
echo '<pre>';
print_r(opcache_get_status());

Resulted in this output:

Array
(
    [...]
    [scripts] => Array
        (
            [/htdocs/temp.php] => Array
                (
                    [full_path] => /htdocs/temp.php
                    [...]
                )

But I expected this output instead:

Array
(
    [...]
    [scripts] => Array
        (
            [(chroot:/home/user1)/htdocs/temp.php] => Array
                (
                    [full_path] => /htdocs/temp.php
                    [...]
                )
            [(chroot:/home/user2)/htdocs/temp.php] => Array
                (
                    [full_path] => /htdocs/temp.php
                    [...]
                )

When using opcache.validate_root=1, same paths across different chroot are listed as one file only. There should be multiple keys.
Prefix is hashed using the inode number, which is working fine (so it's not a collision bug!): https://github.com/php/php-src/blob/7f914620193079b42a91eb84451719e4b376702b/ext/opcache/ZendAccelerator.c#L2673

Also the https://github.com/amnuts/opcache-gui/ doesn't work on invalidating those specific files. Don't know if it's related, but it's possible.

PHP Version
PHP 8.2.28 (cli) (built: Mar 13 2025 18:21:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.28, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.28, Copyright (c), by Zend Technologies
Operating System

Debian 12

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

参照されている ext/opcache/ZendAccelerator.c の箇所から始め、opcache.validate_root=1 の場合に opcache_get_status() が scripts のキーをどのように構築するかを追跡します。同一のパスを別々の chroot で使って例を再現し、その後、各 chroot が個別のキーとして現れ、示されている full_path が保持されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c, php
領域
backend, performance
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。