php / php/php-src

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

未关闭
#18,772 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Extension: opcache Status: Needs Triage
主要语言
C
星标
40.4k
派生
8.1k
平均合并
2 天 13 小时
30 天内合并 PR
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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 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 摘要。