Bug #75579 [Ana]: All Interned Strings Free memory used and PHP crashes
| From: | dmitry@php.net | Date: | Mon, 18 Dec 2017 18:10:23 +0000 |
| Subject: | Bug #75579 [Ana]: All Interned Strings Free memory used and PHP crashes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213163@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75579&edit=1
ID: 75579
Updated by: dmitry@php.net
Reported by: post at minhost dot no
Summary: All Interned Strings Free memory used and PHP
crashes
Status: Analyzed
Type: Bug
Package: opcache
Operating System: CentOS 7.4
PHP Version: 7.1.12
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
I committed a fix into the master branch https://github.com/php/php-src/commit/ce4fb228e033ef896517aea3d01eb8d9ac055366
Could you please verify, if this completely fixes the problem.
Then, I'll backport it into PHP-7.*
Previous Comments:
------------------------------------------------------------------------
[2017-12-17 21:19:06] nikic@php.net
@dmitry: Can you please take a look at this issue? I'm not sure what the best way to fix this
is. Can we just zend_shared_alloc() the string in case the accel_new_interned_string() fails?
An easy way to reproduce this is to enable the file cache, cache some files with
opcache.interned_strings_buffer=8 and then load them using opcache.interned_strings_buffer=0.
------------------------------------------------------------------------
[2017-12-17 21:11:44] nikic@php.net
The issue (presumably) is https://github.com/php/php-src/blob/master/ext/opcache/zend_file_cache.c#L229.
If the script in the file cache uses an interned string, the string is not already in the interned
string buffer, and the interned string buffer has run full, this simply directly returns the string
from the string segment of the cached script. However, the string segment will be freed in https://github.com/php/php-src/blob/master/ext/opcache/zend_file_cache.c#L1467.
The reason why you are only seeing this issue now is due to https://github.com/php/php-src/commit/d82805f097564558d94e3062e87b17d6ccae893f
and the fact that you use revalidate_path=1. Prior to this fix, if revalidate_path=1 opcache
accidentally did not use the interned string buffer for most things, which is why the file cache
also did not contain interned strings.
------------------------------------------------------------------------
[2017-12-15 20:46:48] post at minhost dot no
Finnaly I made some progress: When I deactivate/remove opcache.file_cache= in my settings and only
use opcache in memory, then PHP no longer crashes! So the bug is only visible if you use physical
file cache in opcache in addition to opcache in memory. I was using file cache as a second level
fallback cache (useful when opcache get empty during restarts etc).
Now that I have pinpointed the bug to be when you have enabled both normal opcache and physical file
cache, can someone investigate this bug? Please? I have already posted the complete opcache settings
above in this bug report.
------------------------------------------------------------------------
[2017-12-15 19:50:16] post at minhost dot no
I just now today installed the latest 7.1 development branch from here https://github.com/php/php-src/branches and
tested it. I am sorry to see the problem is still not solved with any of the patches that have been
made so far. PHP still crashes for me after visiting a few WordPress sites. This time it seemed to
happen right after opcache got a automatic OOM restart.
------------------------------------------------------------------------
[2017-12-05 10:44:01] post at minhost dot no
Related To: Bug #75621
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=75579
--
Edit this bug report at https://bugs.php.net/bug.php?id=75579&edit=1