Since I don't have CVS account, I just reply with mail. Anyway, I've posted comment about this bug. Since array_walk() assumes user defiend function only changes element value passed. Destorying array itself causes memory problem and users are not supposed to do that.
unset($array) will not cause problem everytime, since PHP (OS memory manager) does not erase memory when free() is called. Manual has to warn that user may *only* change element value passed, but not others. User has to accept that. IMHO. The same applies to array_filter also. Is there feasible fix for this problem? -- Yasuo Ohgaki [EMAIL PROTECTED] wrote: > ID: 11389 > User updated by: [EMAIL PROTECTED] > Reported By: [EMAIL PROTECTED] > Status: Critical > Bug Type: Arrays related > Operating System: W98 > PHP Version: 4.0.6 > New Comment: > > 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. > > Previous Comments: > ------------------------------------------------------------------------ > > [2001-11-12 18:13:09] [EMAIL PROTECTED] > > 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] [EMAIL PROTECTED] > > 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 > > > ------------------------------------------------------------------------ > > [2001-11-11 06:49:53] [EMAIL PROTECTED] > > Reproduced with 4.2.0-dev (200111080300) on Windows 2000. > > Array_walk seems to be pretty buggy. There were a few reports of crashes using >array_walk, most importantly #12776. > > Reopening. > > ------------------------------------------------------------------------ > > [2001-10-21 01:44:42] [EMAIL PROTECTED] > > I can not reproduce this with PHP 4.1.0RC1. > Could you please try the latest development build from > http://www.php4win.com/ > > > ------------------------------------------------------------------------ > > [2001-06-23 17:31:08] [EMAIL PROTECTED] > > Reproduced with 4.0.7-dev (latest CVS, Win32) > > ------------------------------------------------------------------------ > > 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/?id=11389 > > > Edit this bug report at http://bugs.php.net/?id=11389&edit=1 > > -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]