Bug #11389 Updated: array_walk causes Apache to crash

From: Date: Mon, 25 Mar 2002 03:32:59 +0000
Subject: Bug #11389 Updated: array_walk causes Apache to crash
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-3245@lists.php.net to get a copy of this message
ID: 11389 Updated by: yohgaki@php.net Reported By: sivev@hotmail.com -Status: Analyzed +Status: Closed Bug Type: Arrays related Operating System: ALL PHP Version: 4.2.0-dev New Comment: I added comments to manual. Users are not supposed to change array that is array_walk or array_filter is operating. If you have an idea for feasible fix for this problem, feel free to reopen and fix this. Previous Comments: ------------------------------------------------------------------------ [2002-02-26 21:42:10] yohgaki@php.net I know array walk has problem, but it's not simple to fix.... ------------------------------------------------------------------------ [2001-11-16 02:52:01] derick@php.net It's not critical, cause it does not crash PHP. ------------------------------------------------------------------------ [2001-11-13 04:04:29] sivev@hotmail.com But this is not the real script!! My real script have a lot of code lines and functions, a lot of arrays inside other arrays and so on, i need 'walk' the arrays, and array_walk crash my code sometimes. To work around this bug, i have written my 'my_array_walk' function in PHP script that always behave OK. I don't need the 'array_walk' function, but i think this bug must be fixed. ------------------------------------------------------------------------ [2001-11-12 18:13:09] venaas@php.net Yes, what happens is that array_walk tries to move forward to the next element by calling zend_hash_move_forward_ex() which determines that the hash is inconsistent and bails out. I think this behavior is good enough. This script is asking for trouble. It's important that people can't crash Apache, but I don't mind if weird scripts like this misbehaves. CVS works okay for me since PHP doesn't crash, but bails out. For me I get the same behavior if I remove the call by references (in array_walk call and myfunc declaration). ------------------------------------------------------------------------ [2001-11-11 21:34:20] sniper@php.net Indeed there is something odd going on: <?php $myarr = array(array(1,2,3), array(1,2,3), array(1,2,3)); echo "before\n"; array_walk($myarr, "myfunc"); function myfunc(&$value, $key) { global $myarr; $myarr=null; } echo "after\n"; ?> This script only echo's "before". --Jani ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/11389 -- Edit this bug report at http://bugs.php.net/?id=11389&edit=1

« previous php.bugs (#3245) next »