From:
Operating system: Linux
PHP version: 5.3.2
Package: Performance problem
Bug Type: Bug
Bug description:Memory Leak: zend hash not properly destroyed in CGI main
Description:
------------
After upgrading to PHP 5.3.2, we ran it through Purify and noticed the
following memory leak:
MLK: 32 bytes leaked at 0x9b70ca8
* This memory was allocated from:
calloc [rtlib.o]
_zend_hash_init [zend_hash.c:168]
php_cgi_globals_ctor [cgi_main.c:1429]
allocate_new_resource [TSRM.c:303]
ts_resource_ex [TSRM.c:370]
.
.
.
The problem is that php_cgi_globals_ctor() (the constructor) is calling
zend_hash_init() but there is no corresponding destructor to call
zend_hash_destroy(). I have attached a patch that will fix this.
You will notice in the patch that I had to make changes to
zend_hash_destroy() to prevent a double free. Apparently there are places
that are already calling zend_hash_destroy() for the hash that is
initialized in php_cgi_globals_ctor(), but it is not currently getting
called all of the time. Perhaps a more correct fix would be to find where
these other calls to zend_hash_destroy() are being made and either
eliminate them altogether or make sure they are called all of the time and
not have the destructor function.
--
Edit bug report at http://bugs.php.net/bug.php?id=51760&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=51760&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=51760&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=51760&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=51760&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=51760&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=51760&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=51760&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=51760&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=51760&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=51760&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=51760&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=51760&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=51760&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=51760&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51760&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51760&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=51760&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=51760&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=51760&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=51760&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=51760&r=mysqlcfg