#31446 [Opn->Bgs]: Memory leak in mysql extension

From: Date: Sat, 08 Jan 2005 08:25:41 +0000
Subject: #31446 [Opn->Bgs]: Memory leak in mysql extension
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-71599@lists.php.net to get a copy of this message
ID: 31446 Updated by: georg@php.net Reported By: hexer at studentcenter dot org -Status: Open +Status: Bogus Bug Type: MySQL related Operating System: Linux 2.4 PHP Version: 4.3.10 New Comment: This is a bug in libmysql, not in PHP. Please check http://bugs.mysql.com/bug.php?id=7619 Previous Comments: ------------------------------------------------------------------------ [2005-01-07 23:05:14] hexer at studentcenter dot org 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 this bug report at http://bugs.php.net/?id=31446&edit=1

« previous php.bugs (#71599) next »