|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-01-09 05:52 UTC] Terry at ellisons dot org dot uk
[2014-01-09 05:54 UTC] Terry at ellisons dot org dot uk
[2014-01-09 07:31 UTC] Terry at ellisons dot org dot uk
[2014-01-09 18:17 UTC] Terry at ellisons dot org dot uk
-Status: Open
+Status: Closed
[2014-01-09 18:17 UTC] Terry at ellisons dot org dot uk
[2014-01-10 18:49 UTC] Terry at ellisons dot org dot uk
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 12:00:02 2025 UTC |
Description: ------------ The SHM Interned Strings pool is sized by the opcache.interned_strings_buffer INI parameter. However, there is no guarantee that -- especially for large OPcaches supporting a lot of modules -- that the interned strings pool might not fill. OPcache is then supposed to degrade gracefully into using non-interned memory for overflow strings that would otherwise have been allocated to SHM. I decided to exercise these code paths within the tests environment by the following mod: --- a/ZendAccelerator.c +++ b/ZendAccelerator.c @@ -2492,6 +2495,11 @@ static int zend_accel_init_shm(TSRMLS_D) # if ZEND_EXTENSION_API_NO > PHP_5_5_X_API_NO orig_interned_empty_string = CG(interned_empty_string); CG(interned_empty_string) = accel_new_interned_string("", sizeof(""), 0 TSRMLS_CC); +# if 1 //TERRY + /* Q&D patch to force interned string pool exhaustion */ + ZCSG(interned_strings_end) = CG(interned_strings_top)+128; + CG(interned_strings_end) = ZCSG(interned_strings_end); +# endif # endif # endif This set the strings end point to 128 above the top after initialising the SHM with existing interned strings. This means in practice that the pool will "fill" after only a few string inserts and any remaining string will be handled by the "pool full" path. When I do this, I get a lot of memory leaks. The following is a simple example: Test script: --------------- <?php $c = get_declared_classes(); ?> run with the above patch in OPcache , with and without OPcache enabled. Expected result: ---------------- The failover to non-SHM overflow should be silent. No errors should be raised. Actual result: -------------- $ php56 -d opcache.enable=0 /tmp/test.php $ php56 -d opcache.enable=1 -d opcache.enable_cli=1 /tmp/test.php [Wed Jan 8 18:21:11 2014] Script: '/tmp/test.php' /.../Zend/zend_API.c(1461) : Freeing 0x7F3162054110 (23 bytes), script=/tmp/test.php Last leak repeated 41 times === Total 42 memory leaks detected === Footnote. This highlights that Sysadmins need to able to query capacity / usage information on all fixed size pools and tables.