opcache doesn't list all files with the same path when using chroot (opcache_get_status())
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the referenced ext/opcache/ZendAccelerator.c location and trace how opcache_get_status() builds its scripts keys when opcache.validate_root=1. Reproduce the example with identical paths in separate chroots, then verify that each chroot appears as a distinct key while retaining the shown full_path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100