From: chiujl at gmail dot com
Operating system: RHEL4 x86_64
PHP version: 5.1.5
PHP Bug Type: Scripting Engine problem
Bug description: Looping of class member using foreach causes segfault
Description:
------------
This could be related to bug 31942.
When a global array variable is accessed in both the __construct & __get
method and subsequently looped using foreach, it causes segmentation fault
the second time the variable is accessed.
Reproduce code:
---------------
<?
$data = array(1, 2, 3);
class classA {
private $properties;
function __construct () { $this->properties = $GLOBALS["data"]; }
function __get ($prop) { return $GLOBALS["data"]; }
}
function loopValues () {
$a = new classA();
foreach ($a->values as $i => $v) { }
}
function dumpValues () {
$a = new classA();
var_dump($a->values);
}
loopValues();
dumpValues();
?>
Expected result:
----------------
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
Actual result:
--------------
Segmentation fault
--
Edit bug report at http://bugs.php.net/?id=38638&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=38638&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=38638&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=38638&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38638&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=38638&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38638&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38638&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38638&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38638&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38638&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=38638&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=38638&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38638&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38638&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38638&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38638&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38638&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38638&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38638&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38638&r=mysqlcfg