From: jan at kneschke dot de Operating system: Linux 2.4.x PHP version: 4.3.3RC1 PHP Bug Type: Scripting Engine problem Bug description: small memory leaks found by valgrind
Description: ------------ I just used valgrind on a simple php script and found a small memory leaks in the Zend Engine A patch is attached below. 1. double init of auto_globals in line 473 and 499 because of #ifndef ZTS #define GLOBAL_AUTO_GLOBALS_TABLE CG(auto_globals) #endif 2. a missing free Reproduce code: --------------- $ valgrind --logfile-fd=1 -v --leak-check=yes --show-reachable=yes ~/projects/in-cvs/php4/sapi/cli/php -r "print 'a';" Expected result: ---------------- no leaks :) Actual result: -------------- Index: Zend/zend.c =================================================================== RCS file: /repository/Zend/Attic/zend.c,v retrieving revision 1.162.2.9 diff -u -r1.162.2.9 zend.c --- Zend/zend.c 14 Jun 2003 09:27:34 -0000 1.162.2.9 +++ Zend/zend.c 18 Jul 2003 06:47:51 -0000 @@ -496,7 +496,6 @@ zend_startup_constants(tsrm_ls); GLOBAL_CONSTANTS_TABLE = EG(zend_constants); #else - zend_hash_init_ex(CG(auto_globals), 8, NULL, NULL, 1, 0); scanner_globals_ctor(&ini_scanner_globals TSRMLS_CC); scanner_globals_ctor(&language_scanner_globals TSRMLS_CC); zend_startup_constants(); Index: Zend/zend_ini.c =================================================================== RCS file: /repository/Zend/Attic/zend_ini.c,v retrieving revision 1.23.2.2 diff -u -r1.23.2.2 zend_ini.c --- Zend/zend_ini.c 24 Mar 2003 14:53:13 -0000 1.23.2.2 +++ Zend/zend_ini.c 18 Jul 2003 06:47:52 -0000 @@ -78,6 +78,7 @@ ZEND_API int zend_ini_shutdown(TSRMLS_D) { zend_hash_destroy(EG(ini_directives)); + free(EG(ini_directives)); return SUCCESS; } -- Edit bug report at http://bugs.php.net/?id=24700&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24700&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24700&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=24700&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24700&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24700&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24700&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24700&r=support Expected behavior: http://bugs.php.net/fix.php?id=24700&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24700&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24700&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24700&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24700&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24700&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24700&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24700&r=gnused