From: hexer at studentcenter dot org Operating system: Linux 2.4 PHP version: 4.3.10 PHP Bug Type: MySQL related Bug description: Memory leak in mysql extension
Description: ------------ There is a memory leak when any script that uses mysql_connect is run. The call to init_available_charsets() (libmysql/charset.c:177) allocates some memory but the call to free_charsets() is never made at the end of the script execution. Reproduce code: --------------- <?php // replace params with your mysql host username and password $db=mysql_connect("127.0.0.1","username","password"); mysql_close($db); ?> Actual result: -------------- valgrind --tool=memcheck --leak-check=yes --show-reachable=yes php test.php Valgrind output: ==20923== 64 bytes in 1 blocks are still reachable in loss record 1 of 1 ==20923== at 0x1B900D20: malloc (vg_replace_malloc.c:131) ==20923== by 0x8091E71: my_malloc (/usr/local/src/php-4.3.10/ext/mysql/libmysql/my_malloc.c:22) ==20923== by 0x809708A: init_dynamic_array (/usr/local/src/php-4.3.10/ext/mysql/libmysql/array.c:35) ==20923== by 0x809949B: init_available_charsets (/usr/local/src/php-4.3.10/ext/mysql/libmysql/charset.c:177) Further notes: The call to my_end() (libmysql/my_init.c) contains a call to free_charsets() but my_end() is never called from anywhere. Php was compiled with: ./configure --with-mysql \ --with-xml \ --with-apache=../apache_1.3.33 \ --enable-track-vars \ --with-gd \ --enable-discard-path \ --enable-bcmath \ --enable-gd-native-tt \ --with-freetype-dir=/usr/local \ --with-png-dir=/usr/local \ --with-jpeg-dir=/usr/local \ --with-zlib=/usr/local ------ -Hexer -- Edit bug report at http://bugs.php.net/?id=31446&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31446&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31446&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31446&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=31446&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=31446&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31446&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31446&r=needscript Try newer version: http://bugs.php.net/fix.php?id=31446&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31446&r=support Expected behavior: http://bugs.php.net/fix.php?id=31446&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31446&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31446&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=31446&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31446&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=31446&r=dst IIS Stability: http://bugs.php.net/fix.php?id=31446&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31446&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31446&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=31446&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=31446&r=mysqlcfg