php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31446 Memory leak in mysql extension
Submitted: 2005-01-07 23:05 UTC Modified: 2005-01-08 09:25 UTC
From: hexer at studentcenter dot org Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.3.10 OS: Linux 2.4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hexer at studentcenter dot org
New email:
PHP Version: OS:

 

 [2005-01-07 23:05 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-08 09:25 UTC] georg@php.net
This is a bug in libmysql, not in PHP. 
 
Please check http://bugs.mysql.com/bug.php?id=7619 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 02:01:32 2024 UTC