|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2008-09-23 10:00 UTC] kalle@php.net
 Description:
------------
Creating a new instance of the same class in a class destructor which causes infinite recursion will cause PHP to crash, instead of throwing a memory_limit error.
Dmitry told me to report this so it wouldn't be forgotten.
Reproduce code:
---------------
<?php
	class Crash
	{
		public function __destruct()
		{
			new self;
		}
	}
	new Crash;
?>
Expected result:
----------------
memory_limit error
Actual result:
--------------
Crash
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 08:00:01 2025 UTC | 
Heres another one with __call(): <?php class Test { public function __call($call, Array $args) { call_user_func_array(Array($this, $call), $args); } } $test = new Test; $test->crash(); ?>This one is a little odd, however I get a memory_limit error but straight after it crashes: <?php start: { $a = function($b) use($a) { $a(); }; } goto start; ?>