php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48141 memory leak in zend_execute.c and zend_operators.c
Submitted: 2009-05-04 04:24 UTC Modified: 2009-12-22 01:00 UTC
From: greg at chiaraquartet dot net Assigned: dmitry (profile)
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.3CVS-2009-05-04 (CVS) OS: ubuntu linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: greg at chiaraquartet dot net
New email:
PHP Version: OS:

 

 [2009-05-04 04:24 UTC] greg at chiaraquartet dot net
Description:
------------
When running a simple file that only instantiates objects using autoload, there is a memory leak.

The leak appears to be caused by some combination of string concatenation and exception throwing.  The line that causes the leak is in Pyrus/src/Pyrus/Registry/Sqlite3.php in the constructor:

        if ($path && $path != ':memory:') {
            if (dirname($path) . DIRECTORY_SEPARATOR . '.pear2registry' != $path) {
                $path = $path . DIRECTORY_SEPARATOR . '.pear2registry';
            }
        }

The line "$path = $path . DIRECTORY_SEPARATOR . '.pear2registry';"

leaks the value "/usr/local/lib/php/.pear2registry" on my machine, and the zval allocated for $path.

Reproduce code:
---------------
<?php
// run from checkout of http://svn.pear.php.net/PEAR2/all
function __autoload($class)
{
    if ($class == 'PEAR2_Exception') {
        include __DIR__ . '/Exception/src/Exception.php';
        return;
    }
    $class = str_replace('PEAR2_', '', $class);
    $class = str_replace('_', '/', $class);
    include __DIR__ . '/Pyrus/src/' . $class . '.php';
}
$a = PEAR2_Pyrus_Config::current();


Expected result:
----------------
no output

Actual result:
--------------
user@ubuntu8041:~/workspace/all/Pyrus/tests/AtomicFileTransaction/rmrf$ php -n test.phpt
[Sun May  3 22:58:31 2009]  Script:  'test.phpt'
/home/user/workspace/php5/Zend/zend_execute.c(723) :  Freeing 0xB7B52AE4 (20 bytes), script=test.phpt
[Sun May  3 22:58:31 2009]  Script:  'test.phpt'
/home/user/workspace/php5/Zend/zend_operators.c(1231) :  Freeing 0x088CE1EC (34 bytes), script=test.phpt
=== Total 2 memory leaks detected ===


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-04 08:03 UTC] tony2001@php.net
Dmitry, could you look into it?
 [2009-05-04 10:16 UTC] dmitry@php.net
I'm not able to reproduce it with CVS PHP_5_3.
 [2009-05-04 17:21 UTC] cellog@php.net
user@ubuntu8041:~/workspace/php5$ cat config.nice
#! /bin/sh
#
# Created by configure

'./configure' \
'--enable-debug' \
'--with-zlib' \
'--with-bz2=shared' \
'--enable-cgi' \
"$@"
user@ubuntu8041:~/workspace/php5$ uname -a
Linux ubuntu8041 2.6.24-23-generic #1 SMP Wed Apr 1 21:47:28 UTC 2009 i686 GNU/Linux
user@ubuntu8041:~/workspace/php5$ cat CVS/Tag
TPHP_5_3
user@ubuntu8041:~/workspace/php5$ 



 [2009-05-04 17:22 UTC] cellog@php.net
I'm using Ubuntu in a VMWare Fusion image in a MacBook Pro, in case that is helpful
 [2009-05-06 18:49 UTC] jani@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2009-05-14 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-12-15 00:44 UTC] felipe@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-12-22 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 17:01:30 2025 UTC