#38638 [Fbk->Csd]: Looping of class member using foreach causes segfault
| From: | chiujl at gmail dot com | Date: | Tue, 29 Aug 2006 08:59:33 +0000 |
| Subject: | #38638 [Fbk->Csd]: Looping of class member using foreach causes segfault | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101476@lists.php.net to get a copy of this message | ||
ID: 38638
User updated by: chiujl at gmail dot com
Reported By: chiujl at gmail dot com
-Status: Feedback
+Status: Closed
Bug Type: Scripting Engine problem
Operating System: RHEL4 x86_64
PHP Version: 5.1.5
New Comment:
Verified no problem in the latest 5.2 snapshot.
Previous Comments:
------------------------------------------------------------------------
[2006-08-29 07:40:47] tony2001@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.2-win32-latest.zip
Can't reproduce.
------------------------------------------------------------------------
[2006-08-29 06:06:53] chiujl at gmail dot com
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 this bug report at http://bugs.php.net/?id=38638&edit=1