|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-05-06 23:57 UTC] russell dot tempero at rightnow dot com
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.
Patcheszend_hash_init_MLK.diff (last revision 2010-05-06 21:57 UTC by russell dot tempero at rightnow dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 16:00:02 2025 UTC |
This hash is destroyed on shutdown by this function: static PHP_MSHUTDOWN_FUNCTION(cgi) { zend_hash_destroy(&CGIG(user_config_cache)); UNREGISTER_INI_ENTRIES(); return SUCCESS; }