[php-maint] Bug#577009: Bug#577009: Bug#577009: php5-cgi: php-cgi uses 500+ mb memory

sean finney seanius at debian.org
Sat Apr 17 07:22:56 UTC 2010


reassign 577009 php5-xcache
retitle 577009 php5-cgi + xcache == memory leak
found 577009 1.3.0-6
thanks

On Fri, Apr 16, 2010 at 02:51:47PM +0200, Olaf van der Spek wrote:
> Without php5-xcache:
> 14414 www-data  20   0  144m  21m 4184 S    9  0.3  12:20.07 php-cgi
> 14412 www-data  20   0  141m  18m 4364 S    7  0.2  10:36.11 php-cgi
> 14458 www-data  20   0  141m  18m 4424 S   10  0.2  13:37.94 php-cgi
> 14444 www-data  20   0  139m  15m 4188 S    6  0.2  12:18.15 php-cgi

yes, it seems that php5-xcache is indeed the culprit, but this info
doesn't help a great deal.  an example closer to the information that
we *actually* need to get:

rangda[/home/sean] cat << EOF > foo.php                                      :)
heredoc> <?php echo "hello\n"; ?>
heredoc> EOF

rangda[/home/sean] valgrind --leak-check=full php5-cgi foo.php               :)
==19928== Memcheck, a memory error detector
==19928== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==19928== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for copyright info
==19928== Command: php5-cgi foo.php
==19928== 
X-Powered-By: PHP/5.3.2-1
Content-type: text/html

hello
==19928== 
==19928== HEAP SUMMARY:
==19928==     in use at exit: 73,564 bytes in 2,972 blocks
==19928==   total heap usage: 36,747 allocs, 33,775 frees, 5,261,639 bytes allocated
==19928== 
==19928== 21,468 bytes in 1,376 blocks are definitely lost in loss record 76 of 76
==19928==    at 0x4C221A7: malloc (vg_replace_malloc.c:195)
==19928==    by 0x65C6D6: zend_strndup (in /usr/bin/php5-cgi)
==19928==    by 0xE26CA78: ???
==19928==    by 0x688E85: zend_hash_copy (in /usr/bin/php5-cgi)
==19928==    by 0xE26CD74: ???
==19928==    by 0xE268E89: ???
==19928==    by 0xE26E053: ???
==19928==    by 0x67A349: zend_execute_scripts (in /usr/bin/php5-cgi)
==19928==    by 0x625FF7: php_execute_script (in /usr/bin/php5-cgi)
==19928==    by 0x708063: main (in /usr/bin/php5-cgi)
==19928== 
==19928== LEAK SUMMARY:
==19928==    definitely lost: 21,468 bytes in 1,376 blocks
==19928==    indirectly lost: 0 bytes in 0 blocks
==19928==      possibly lost: 0 bytes in 0 blocks
==19928==    still reachable: 52,096 bytes in 1,596 blocks
==19928==         suppressed: 0 bytes in 0 blocks
==19928== Reachable blocks (those to which a pointer was found) are not shown.
==19928== To see them, rerun with: --leak-check=full --show-reachable=yes
==19928== 
==19928== For counts of detected and suppressed errors, rerun with: -v
==19928== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 28 from 10)

rangda[/home/sean] sudo apt-get --purge remove php5-xcache                   :)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  php5-xcache*
0 upgraded, 0 newly installed, 1 to remove and 87 not upgraded.
After this operation, 393kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 293915 files and directories currently installed.)
Removing php5-xcache ...
Purging configuration files for php5-xcache ...
Processing triggers for libapache2-mod-php5 ...
Reloading web server config: apache2.

rangda[/home/sean] valgrind --leak-check=full php5-cgi foo.php               :)
==20038== Memcheck, a memory error detector
==20038== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==20038== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for copyright info
==20038== Command: php5-cgi foo.php
==20038== 
X-Powered-By: PHP/5.3.2-1
Content-type: text/html

hello
==20038== 
==20038== HEAP SUMMARY:
==20038==     in use at exit: 52,112 bytes in 1,596 blocks
==20038==   total heap usage: 19,006 allocs, 17,410 frees, 3,656,847 bytes allocated
==20038== 
==20038== LEAK SUMMARY:
==20038==    definitely lost: 0 bytes in 0 blocks
==20038==    indirectly lost: 0 bytes in 0 blocks
==20038==      possibly lost: 0 bytes in 0 blocks
==20038==    still reachable: 52,112 bytes in 1,596 blocks
==20038==         suppressed: 0 bytes in 0 blocks
==20038== Reachable blocks (those to which a pointer was found) are not shown.
==20038== To see them, rerun with: --leak-check=full --show-reachable=yes
==20038== 
==20038== For counts of detected and suppressed errors, rerun with: -v
==20038== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 28 from 10)
 
i imagine it shouldn't be too difficult to figure out how to get a command
line invokation of php5-cgi to serve up one request for your site/app.
so, please do that and report if there are leaks in any other places.
bonus points if you can figure out how to get the debug symbols from
php5-xcache installed--i couldn't, at least in a way that got the ???
functions (which are from xcache's .so) to show up correctly in valgrind.

	sean
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-php-maint/attachments/20100417/eb67cade/attachment-0001.pgp>


More information about the pkg-php-maint mailing list