ID: 43310
Comment by: felipensp at gmail dot com
Reported By: commander at graphicore dot de
Status: Open
Bug Type: Reproducible crash
Operating System: Linux, WinXp
PHP Version: 5.2.5
New Comment:
Works fine in PHP 5.3.0-dev (cli) (built: Nov 15 2007 18:47:59)
Previous Comments:
------------------------------------------------------------------------
[2007-11-15 23:18:37] commander at graphicore dot de
Description:
------------
The code crashes the Apache process immediately. The crash occurs with
other functions(array_values, print_r, gettype, ...) instead of
array_keys() as well.
To avoid the crash delete the reference in Line 7 to copy the array
that contains the references. That was intended anyway.
However, it took hours to find the problem. A Runtime-Error or
something like that would be nice.
Systems:
Linux(Ubuntu): Apache/2.2.4 PHP/5.2.3-1ubuntu6
Apache error.log:
[Thu Nov 15 23:18:48 2007] [notice] child pid 2874 exit signal
Segmentation fault (11)
WinXp: Apache/2.2.3 (Win32) PHP Version 4.4.4
Apache error.log:
[Thu Nov 15 23:43:43 2007] [notice] Parent: child process exited with
status 3221225477 -- Restarting.
best regards
Reproduce code:
---------------
<?php
class aClass{
var $arr;
function makeObjects($load){
for($i = 1; $load >= $i; $i++){
$this->arr['objects'][$i] = new aClass();
$this->arr['objects'][$i]->arr =& $this->arr;//copying
$this->arr avoids the crash
}
echo count($this->arr['objects']).' objects are loaded'."\n";
}
}
$root = new aClass();
$objects[0] =& $root;
$root->arr['objects'] =& $objects;
$load = 3;
$root->makeObjects($load);
unset($objects[$load]);//unset the last object
array_keys($root->arr['objects']);//crash
echo count($objects).' objects are loaded';
?>
Expected result:
----------------
4 objects are loaded
3 objects are loaded
Actual result:
--------------
the process crashes, no warning, no error
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43310&edit=1