|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-11-16 00:32 UTC] felipensp at gmail dot com
[2007-11-16 00:51 UTC] jani@php.net
[2007-11-16 10:32 UTC] crrodriguez+php at suse dot de
[2007-11-18 16:52 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 09:00:01 2025 UTC |
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