php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46156 Infinite recursion in class destructor causes crash
Submitted: 2008-09-23 10:00 UTC Modified: 2016-03-26 23:31 UTC
Votes:5
Avg. Score:3.0 ± 1.8
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: kalle@php.net Assigned: dmitry (profile)
Status: Duplicate Package: Scripting Engine problem
PHP Version: 5.3, 6 (2009-09-24) OS: *
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: kalle@php.net
New email:
PHP Version: OS:

 

 [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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-05 07:28 UTC] kalle@php.net
I've discovered one more crash and reported here of the same type:
http://bugs.php.net/bug.php?id=46754
 [2009-02-16 12:19 UTC] kalle@php.net
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();
?>
 [2009-03-13 11:12 UTC] kalle@php.net
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;
?>
 [2016-03-26 23:31 UTC] nikic@php.net
-Status: Assigned +Status: Duplicate
 [2016-03-26 23:31 UTC] nikic@php.net
Closing as duplicate of bug #64280. It's newer, but has more discussion.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 13:01:28 2025 UTC