From:             greg at chiaraquartet dot net
Operating system: ubuntu linux
PHP version:      5.3CVS-2009-05-04 (CVS)
PHP Bug Type:     Scripting Engine problem
Bug description:  memory leak in zend_execute.c and zend_operators.c

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:
--------------
u...@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 ===


-- 
Edit bug report at http://bugs.php.net/?id=48141&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=48141&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=48141&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=48141&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=48141&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=48141&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=48141&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=48141&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=48141&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=48141&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=48141&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=48141&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=48141&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=48141&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=48141&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=48141&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=48141&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=48141&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=48141&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=48141&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=48141&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=48141&r=mysqlcfg

Reply via email to