|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51868 Possible memleak detected
Submitted: 2010-05-20 09:36 UTC Modified: 2010-05-30 08:22 UTC
From: frame at mudox dot de Assigned:
Status: Closed Package: Class/Object related
PHP Version: Irrelevant OS: Windows x32/Unix x64
Private report: No CVE-ID: None
 [2010-05-20 09:36 UTC] frame at mudox dot de
Unfortanley, I cannot reproduce the code (expect I can send you the files) so I can just describe whats going on:

I have registered a loader for some classes. These classes are container for holding further classes of the same type. A simple tree structure.

Last I changed some static function in the class and wrote instead of the self-keyword the classname, which also should work.

self::myfunction() to myclass::myfunction()

But the result was depending on script line and method after executing the 
affected class method:

"class not found in line 0" or (the same class was loaded few line before without problems)
"undefined class constant xzy in line 0" (which was actually defined)

Changing the classname-word to self has solved the problem.

I have testing the script on Windows 5.3.0 and Unix 5.2.6 with the same result.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-20 11:43 UTC]
-Status: Open +Status: Feedback
 [2010-05-20 11:43 UTC]
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.

 [2010-05-30 05:23 UTC] frame at mudox dot de
-Summary: Possible memleak detected +Summary: PHP should crash or abort instead wrong messages appear -Status: Feedback +Status: Open -Operating System: Windows/Unix +Operating System: Windows x32/Unix x64
 [2010-05-30 05:23 UTC] frame at mudox dot de -> useless!

PHP isn't crashing or something. PHP just outputs an error message where no error is...

A simple example:

I get a "must not throw within __toString()"-Error in line 0
because a NULL-Value is supplied to a function where a integer is expected. Fine.

This is the stack:

#0  mdx_driver->getInfo() called at ...
#1  mdx_driver->__toString() called at ....
#2  mdx_driver->__construct(mdx_error_handler, 10000000, Array ()) called at ...

This value is hold on class construct:

public function __construct($intern_name, $version, $config = array()) {
    $this->_config = $config;
    $this->_private = $config;
    $this->_version = $version;
    $this->_intern_name = $intern_name;

Before getInfo() is called, I put a 

And I get: NULL!!! But you can see, on construct $version is 1000000!

See the stack. There is not other method changing the value from $_version. The value will change in NULL. 

Other observations:

The $_version is declared and I get this error.
If $_version is generated by runtime, I get no error from this var. Instead, the
next declared class variable will "recognized" as Null.

That I know: The error isn't specific. It can happening whereever the situation is suitable and gives "not exists" or wrong-value-messages.

The error is a result of object-recursion and callbacks. When the call will turn into a loop. PHP should crash or abort through canceling call-loop at time limit. Instead various wrong error messages occur.

Anyway. It's there. If you like to get my files to see with own eyes, I will do.

I would say it is a memleak. Caused by my code so there is my bug but that shouldn't be possible and somebody could use it.
 [2010-05-30 08:22 UTC] frame at mudox dot de
-Summary: PHP should crash or abort instead wrong messages appear +Summary: Possible memleak detected -Status: Open +Status: Closed
 [2010-05-30 08:22 UTC] frame at mudox dot de
I noticed, that previous comment isn't liked to that "bug" - Because the constructer called a method which takes a log and call __toString() on the object. As the construct isn't finished the value isn't there.

But this doesn't explain why PHP doesn't find hardcoded Class-Definition at runtime, see post #1. If something went wrong with my code than PHP should give a warning if it detects such things?
"in line 0" clearly says that PHP doesn't know whats going on here because there is no stack. Why isn't?

I think the method is called again in a throwed exception. Therefore line 0. But this behaviour is not the best one...
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 17:01:28 2024 UTC