#43179 [Opn->Bgs]: Segfault on combo of recursive array, class members and variable variables

From: Date: Fri, 02 Nov 2007 17:07:42 +0000
Subject: #43179 [Opn->Bgs]: Segfault on combo of recursive array, class members and variable variables
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-119247@lists.php.net to get a copy of this message
 ID:               43179
 Updated by:       johannes@php.net
 Reported By:      php at lorddeath dot net
-Status:           Open
+Status:           Bogus
 Bug Type:         Reproducible crash
 Operating System: Windows / Linux
 PHP Version:      5.2.4
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

That's an infinite recursion which will use all stack space.


Previous Comments:
------------------------------------------------------------------------

[2007-11-02 15:59:07] php at lorddeath dot net

Sorry; got the code wrong.  This, however, segfaults as "expected":
<?
class MC {
	public $Vars = array();
	public function Execute() {
		foreach ($this->Vars as $k => $v) { $$k = $v; }
		$MyArr['Var'] = $MyArr;
		$MC = new MC();
		$MC->Vars = $MyArr;
		$MC->Execute();
	}
}
$MyArr = array();
$MyArr['Var'] = $MyArr;
$MC = new MC();
$MC->Vars = $MyArr;
$MC->Execute();
echo "Hello world.";
?>

------------------------------------------------------------------------

[2007-11-02 15:55:46] php at lorddeath dot net

Description:
------------
When the code I've supplied is executed, PHP crashes, leaving a
segfault message in Apache's log.

The code looks a little perverse, though a variation on it had a real
use in my situation, but regardless, PHP shouldn't segfault, no matter
how perverse the code is :)

Reproduce code:
---------------
class MC {
	public $Vars = array();
	public function Execute() {
		if (!defined('DONE')) {
			define('DONE', true);
			foreach ($this->Vars as $k => $v) { $$k = $v; }
			$MyArr['Var'] = $MyArr;
			$MC = new MC();
			$MC->Vars = $MyArr;
			$MC->Execute();
		}
	}
}
$MyArr = array();
$MyArr['Var'] = $MyArr;
$MC = new MC();
$MC->Vars = $MyArr;
$MC->Execute();
echo "Hello world.";

Expected result:
----------------
"Hello world." should be printed.

Actual result:
--------------
Nothing is printed, and a segfault line is added to
/var/log/apache2/error.log:
[Fri Nov 02 15:50:11 2007] [notice] child pid 23282 exit signal
Segmentation fault (11)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=43179&edit=1


Thread (3 messages)

« previous php.bugs (#119247) next »