Bug #75579 [Com]: All Interned Strings Free memory used and PHP crashes

From: Date: Tue, 19 Dec 2017 11:17:51 +0000
Subject: Bug #75579 [Com]: All Interned Strings Free memory used and PHP crashes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213166@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 Comment by: post at minhost dot no 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: Thank you both, @nikic and @dmitry! I want to test the patch, however can I apply the patch from @dmitry directly into PHP 7.1.12? Or is it needed to use the 7.1.13 branch from https://github.com/php/php-src/tree/PHP-7.1.13 ? Previous Comments: ------------------------------------------------------------------------ [2017-12-18 18:10:22] dmitry@php.net 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.* ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ 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

« previous php.bugs (#213166) next »