Bug #81365 [Opn]: Using OPcache with SHM and file causes 'Allowed memory size of ... bytes exhau'

From: Date: Wed, 18 Aug 2021 09:33:15 +0000
Subject: Bug #81365 [Opn]: Using OPcache with SHM and file causes 'Allowed memory size of ... bytes exhau'
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235923@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81365&edit=1

 ID:                 81365
 Updated by:         nikic@php.net
 Reported by:        wedwards at cyberfusion dot nl
 Summary:            Using OPcache with SHM and file causes 'Allowed
                     memory size of ... bytes exhau'
 Status:             Open
 Type:               Bug
 Package:            opcache
 Operating System:   Debian 10
 PHP Version:        7.4.22
 Block user comment: N
 Private report:     N

 New Comment:

We haven't been testing this kind of file_cache_only config switch until now.

For the file_cache_only=0 -> file_cache_only=1 direction, I found one minor issue, currently
testing at https://github.com/php/php-src/pull/7384.

For the file_cache_only=1 -> file_cache_only=0 direction, current master is clean, but there are
major problems for earlier versions. For now, I can only recommend to clear the file cache if you
flip the file_cache_only setting.


Previous Comments:
------------------------------------------------------------------------
[2021-08-17 14:31:08] wedwards at cyberfusion dot nl

This seems to be related: https://bugs.php.net/bug.php?id=80864 , the
difference being that I'm only seeing this issue with opcache.file_cache_only disabled.

> Looks like some kind of memory corruption is occurring in shm+file_cache mode. 
> The memory exhaustion error is (likely) just the way it manifests.
> 
> I won't be able to diagnose this without some way to reproduce the issue 
> though.

I guess reproducing it should be easy when using PHP 7.4:

1. Enable opcache.file_cache and opcache.file_cache_only
2. Let the OPcache on disk grow (I've seen this issue with OPcache dirs around 120 MiB)
3. Disable opcache.file_cache_only

------------------------------------------------------------------------
[2021-08-17 13:23:17] nikic@php.net

Looks like some kind of memory corruption is occurring in shm+file_cache mode. The memory exhaustion
error is (likely) just the way it manifests.

I won't be able to diagnose this without some way to reproduce the issue though.

------------------------------------------------------------------------
[2021-08-16 15:23:44] wedwards at cyberfusion dot nl

Description:
------------
I recently disabled opcache.file_cache_only (default). opcache.file_cache is set, however. This
caused the issue below on 1 out of estimated 100 websites.

When using OPcache with SHM Cache *or* File Cache, OPcache works as expected.

When using OPcache with SHM Cache *and* File Cache, memory is exhausted:

"Allowed memory size of 268435456 bytes exhausted (tried to allocate 70064798980 bytes)"

... followed by PHP-FPM logging the process ended with SIGSEGV.

I 'fixed' this issue by physically removing the OPcache directory tree. This leads me to
believe the issue is with the size of this website's OPcache, which is 87 MiB (the second
largest one is 69 MiB). I expect this issue to reoccur as the OPcache grows.
 
I found one other report of this behaviour (see last lines): https://github.com/Yoast/wordpress-seo/issues/6334#issuecomment-269647620



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81365&edit=1


Thread (4 messages)

« previous php.bugs (#235923) next »