|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-11-02 15:55 UTC] 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)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 18:00:01 2025 UTC |
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."; ?>