#43229 [Opn->Ver]: array_walk crashes with a segmentation fault

From: Date: Fri, 09 Nov 2007 23:07:02 +0000
Subject: #43229 [Opn->Ver]: array_walk crashes with a segmentation fault
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-119405@lists.php.net to get a copy of this message
ID: 43229 Updated by: stas@php.net Reported By: tobsn@php.net -Status: Open +Status: Verified Bug Type: Reproducible crash Operating System: CentOS PHP Version: 5.2CVS-2007-11-09 (CVS) New Comment: Looks like a problem happens because array is modified while array_walk is walking it. Previous Comments: ------------------------------------------------------------------------ [2007-11-09 20:45:28] tobsn@php.net Description: ------------ strace doesnt output anything - it just cuts the output with a segfault. if you change the variable from $thiskeyword to something else without "this" at the start, it works correctly... ;) Reproduce code: --------------- <?php $stopwords = array( 'this', 'a', 'the', 'is' ); $keyword = explode( ' ', 'this is a big problem' ); for( $i = 0; $i < 1000; $i++ ) { $thiskeyword = $keyword; array_walk( $thiskeyword, create_function('$v,$k','global $thiskeyword,$stopwords;if(in_array($v,$stopwords)){unset($thiskeyword[$k]);}')); } ?> Actual result: -------------- Segmentation Fault ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43229&edit=1

« previous php.bugs (#119405) next »