ID: 45178 User updated by: thomas dot jarosch at intra2net dot com Reported By: thomas dot jarosch at intra2net dot com Status: Closed Bug Type: Reproducible crash Operating System: Linux PHP Version: 5.3CVS-2008-06-04 (snap) Assigned To: dmitry New Comment:
Thanks, Dmitry! Your fix works fine for both bugs. Previous Comments: ------------------------------------------------------------------------ [2008-07-24 13:38:22] [EMAIL PROTECTED] This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. ------------------------------------------------------------------------ [2008-07-16 13:20:31] thomas dot jarosch at intra2net dot com Thanks for looking into this, Dmitry! So there are actually two problems, one memory corruption reported here and one memory leak report in #33595 or are they both memory corruptions? ------------------------------------------------------------------------ [2008-07-15 11:42:00] [EMAIL PROTECTED] The simplest case for this memory corruption. <?php class Foo { function Foo() { $this->error = array($this,$this); } } $a =& new Foo(); ------------------------------------------------------------------------ [2008-07-15 07:37:50] [EMAIL PROTECTED] At first, you have a serious issue in your code. "static" variables MUST NOT be asigned by reference, because they are already references. As result the singleton pattern just doesn't work. BTW the bug is really exists. The simplified test case follows(changing "=& new" into "= new" fixes memory corruption). <?php class Horde_History { function raiseError() { return debug_backtrace(); } function Horde_History() { $this->error = $this->raiseError(); echo "Memory usage: " . memory_get_usage() . "\n"; } } for ($i=0;$i<100000;$i++) { $a =& new Horde_History(); } ?> ------------------------------------------------------------------------ [2008-06-05 09:13:20] thomas dot jarosch at intra2net dot com Actually, the reproduce code from #33595 also leaks memory. The statement about Horde is not 100% correct as only some singleton functions are affected. I mixed it up with another reference problem I fixed a while ago. Nontheless memory is leaked :-) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/45178 -- Edit this bug report at http://bugs.php.net/?id=45178&edit=1