#34907 [Opn->Fbk]: Segfault when overriding class vars in foreach loop
ID: 34907
Updated by: tony2001@php.net
Reported By: steemann at globalpark dot de
-Status: Open
+Status: Feedback
Bug Type: Scripting Engine problem
Operating System: Linux 2.6.10-5-68
PHP Version: 5.1.0RC3
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
Works perfectly here.
If you still able to reproduce it - please provide more info (like SAPI
you're using, gdb backtrace etc).
Previous Comments:
------------------------------------------------------------------------
[2005-10-18 13:48:19] steemann at globalpark dot de
Description:
------------
When assigning class variables to the results of a foreach
loop and using the variables inside the loop, I am getting
a segfault in 5.1RC3.
The problem occurs for class variables only. When doing the
same with local variables, it does not crash. It also does
not crash if the $this->vars["one"] is not used inside the
foreach loop.
If the foreach loop is used without setting the key for the
result it also won't crash, e.g.:
foreach $foo as $this->vars["two"]
instead of
foreach $foo as $this->vars["one"]=>$this->vars["two"]
won't crash.
I know code like this should never be written but Smarty
actually does a lot of stuff like this so it won't work
with 5.1.0RC3.
Reproduce code:
---------------
class x
{
function run()
{
$foo=array("0","1");
foreach ($foo as $this->vars["one"]=>$this->vars["two"])
var_dump($this->vars["one"]);
}
}
$x=new x;
$x->run();
Expected result:
----------------
in PHP 5.1.0b3:
int(0)
int(1)
Actual result:
--------------
in PHP 5.1.0RC3:
int(0)
NULL
Speicherzugriffsfehler (segmentation fault)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34907&edit=1
Thread (3 messages)