php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80864 opcache.file-cache - problems on shared hosting
Submitted: 2021-03-14 16:41 UTC Modified: 2021-03-17 09:35 UTC
Votes:11
Avg. Score:4.5 ± 0.7
Reproduced:11 of 11 (100.0%)
Same Version:9 (81.8%)
Same OS:4 (36.4%)
From: t dot fronk92 at gmx dot de Assigned:
Status: Open Package: opcache
PHP Version: 7.4.16 OS: Debian 10
Private report: No CVE-ID: None
 [2021-03-14 16:41 UTC] t dot fronk92 at gmx dot de
Description:
------------
Hi,

i have a server with multiple WordPress Websites. Every Website has his own User and PHP-FPM Pool.

I tried to activate OPcache securely - because of the Shared Cache Problem - with this settings in every Pool:

php_admin_value[opcache.enable] = 1
php_admin_value[opcache.enable_cli] = 0
php_admin_value[opcache.memory_consumption] = 256
php_admin_value[opcache.max_accelerated_files] = 32531
php_admin_value[opcache.validate_timestamps] = 1
php_admin_value[opcache.revalidate_freq] = 0
;php_admin_value[opcache.fast_shutdown] = 0
php_admin_value[opcache.file_cache] = /home/website1/opcache
php_admin_value[opcache.file_cache_only] = 1
php_admin_value[opcache.validate_permission] = 1

Every Pool has his own settings for file-cache. I understand these settings that there is no shared memory... only the file-cache with 256 MB for every website.

But it didnt work as expected. NGINX has many SEGFAULTS with PHP7.4 in error.log. When i deactivate OPcache all is working fine.

With PHP7.3 i never get these SEGFAULTS.

Maybe there is a Bug in PHP or Configs are wrong - i really dont know.

I hope you can help me or show me a working solution. THX

Test script:
---------------
I dont have.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-17 09:29 UTC] php at i8i dot fr
Hi,

  I get this problem too when PHP switch from 7.4.15 to 7.4.16.

  I had to purge all Opcache file cache.

  So in your case, try to remove all this folders : /home/website1/opcache/*

Best regards,

Arnaud
 [2021-03-17 09:35 UTC] nikic@php.net
@php at i8i dot fr: That's odd. There has only been a very small number of changes to opcache between PHP 7.4.15 and PHP 7.4.16: https://github.com/php/php-src/compare/PHP-7.4.15...PHP-7.4.16#diff-b66a794224587a12f8650298f931f4feafb7734f00885ad885f609a68e840949 Both of these changes don't affect file cache.
 [2021-03-17 10:15 UTC] php at i8i dot fr
I'm pretty sure. I got the problem on 3 vhosts on 2 different servers. It worked with the same fix.

Here was the errors (even with 2G of memory limit) :

[16-Mar-2021 15:21:04 Europe/Paris] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 40747520404 bytes) in /var/www/***/www/vendor/twig/twig/src/Extension/EscaperExtension.php on line 204
[16-Mar-2021 20:27:37 Europe/Paris] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 36081806504 bytes) in /var/www/***/www/vendor/twig/twig/src/Extension/EscaperExtension.php on line 204

Mar 16 15:21:15 vm-dev kernel: [1157155.218584] php-fpm7.4[23089]: segfault at 8 ip 000056182eb6040d sp 00007ffc8d1f0100 error 4 in php-fpm7.4[56182e94c000+26d000]
Mar 16 20:27:46 vm-dev kernel: [1175545.476694] php-fpm7.4[6717]: segfault at 7fe7b5462dc8 ip 0000558c3ef4d3c4 sp 00007ffcf683c8a0 error 4 in php-fpm7.4[558c3ed39000+26d000]
 [2021-03-18 00:13 UTC] t dot fronk at gmx dot net
I have these Problems with all 7.4 Versions, since release. When opcache.file-cache and opcache.file-cache-only are active -> i only get problems.

Removing the file-cache folder is only a very small fix. On next service restart (systemctl restart php7.4-fpm) i get the same Problems - with "reload" it needs a little bit more time to crash.

But the result is the same:
opcache.file-cache with opcache.file-cache-only looks very buggy in 7.4.

I want to use this function on a shared hosting server with multiple websites. So i read the PHP Docs and i understand that opcache.file-cache and opcache.file-cache-only can solve these security problems because there is no shared opcache and every website has his own opcache-folder.

But it dont work as expected.

Now i use OPcache without file-cache and these settings:

php.ini:
opcache.enable = 1
opcache.memory_consumption = 5120
opcache.interned_strings_buffer = 64
opcache.max_accelerated_files = 1000000
opcache.validate_timestamps = 1
opcache.revalidate_freq = 0
opcache.validate_permission = 1
opcache.validate_root = 1
...rest Default

FPM-POOL:
php_admin_value[opcache.enable] = 1
php_admin_value[opcache.restrict_api] = /home/website123/wpdocs/
php_admin_value[disable_functions] = opcache_get_configuration,opcache_get_status,...

This solutions works now without problems - or better said: until now :)
 [2021-03-19 14:31 UTC] php at i8i dot fr
I guess you are right. I purged all OPCache files and I got the problem again today on a WordPress on an other server :

[19-Mar-2021 14:55:16 Europe/Paris] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 130942696452 bytes) in /var/www/xxx-DEV/www/wp-includes/load.php on line 1402
Mar 19 14:55:16 krm1 kernel: [1065426.121559] php-fpm7.4[26973]: segfault at 26 ip 000055a3a315440d sp 00007ffd79c1a200 error 4 in php-fpm7.4[55a3a2f40000+26d000]

OPCache folders were purged, php7.4-fpm restarted and PHP version did not changed since.

The only settings I changed are opcache.error_log, opcache.file_cache and opcache.lockfile_path.

I guess I will deactivate opcache.file_cache too...
 [2021-03-19 15:16 UTC] t dot fronk at gmx dot net
With opcache.file-cache i also get lots of "recv() failed (104 connection reset by peer)" entries in nginx error.log.
 [2021-12-22 08:16 UTC] mr-manuel at outlook dot com
I have a similar problem on various PHP version (7.4.26, 8.0.13, 8.1.0) on shared hosting (using Debian 11). Every domain has his own PHP-FPM pool, but when I check which scripts are cached, I see the scripts of all pools of the same PHP-FPM version. This even, if the script is executed in the domain pool and restrict_api is enabled.

My opcache settings are:

# /etc/php/7.4/fpm/pool.d/domain-1.conf
php_admin_flag[opcache.enable] = 1
php_admin_value[opcache.memory_consumption] = 128
php_admin_value[opcache.interned_strings_buffer] = 8
php_admin_value[opcache.max_accelerated_files] = 16229
php_admin_flag[opcache.validate_timestamps] = 1
php_admin_flag[opcache.save_comments] = 1
php_admin_value[opcache.revalidate_freq] = 1
php_admin_flag[opcache.fast_shutdown] = 1
php_admin_value[opcache.restrict_api] = "/var/www/html/domain-1.com"
... rest is default

The settings for all domains are the same, except the domain path and config file name.

Someone have the same behaviour?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 03 22:01:26 2024 UTC