From: commander at graphicore dot de
Operating system: Linux, WinXp
PHP version: 5.2.5
PHP Bug Type: Reproducible crash
Bug description: PHP crash with References and unset
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 bug report at http://bugs.php.net/?id=43310&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=43310&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=43310&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=43310&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=43310&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43310&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=43310&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43310&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43310&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43310&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43310&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43310&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=43310&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=43310&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43310&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43310&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43310&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43310&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43310&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43310&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43310&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43310&r=mysqlcfg