#35567 [Opn->Fbk]: DirectoryIterator segfaults after Notice

From: Date: Tue, 06 Dec 2005 09:02:16 +0000
Subject: #35567 [Opn->Fbk]: DirectoryIterator segfaults after Notice
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-89813@lists.php.net to get a copy of this message
ID: 35567 Updated by: helly@php.net Reported By: judas dot iscariote at gmail dot com -Status: Open +Status: Feedback Bug Type: SPL related -Operating System: linux amd64 +Operating System: * PHP Version: 5CVS-2005-12-06 (CVS) -Assigned To: +Assigned To: helly New Comment: Several things: - storing the output of an iterator in an array is most likely wrong. Instead use a FilterIterator to wrap the input iterator (DirectoryIterator in your case) and work on its result. - $dirs = new DirectoryIterator($dirs->dirname()); pretty much sounds like an endless loop. *Which does crash*. Try using xdebug to detect such loops or simply place a var_dump() showing what you are creating the iterator on. - It seems you are trying some kind of recursion. Use RecursiveIteratorIterator with RecursiveDirectoryIterator for that. - To be able to give you a real answer i would need real code that crashes - short reproducing script. Previous Comments: ------------------------------------------------------------------------ [2005-12-06 08:49:07] judas dot iscariote at gmail dot com $dirs = new DirectoryIterator( $this->dirname() ); I mean... :-( ------------------------------------------------------------------------ [2005-12-06 08:47:55] judas dot iscariote at gmail dot com if useful.. it is crashing with something like this.. $dirs = new DirectoryIterator( $this->dirname );... of course $this->dirname contains a **valid** directory path. ------------------------------------------------------------------------ [2005-12-06 07:49:17] judas dot iscariote at gmail dot com php -v PHP 5.1.2-dev (cgi) (built: Dec 6 2005 03:03:55) (DEBUG) ------------------------------------------------------------------------ [2005-12-06 07:45:24] judas dot iscariote at gmail dot com Description: ------------ DirectoryIterator class is segfaulting after a Notice : Notice - Object of class DirectoryIterator could not be converted to int ( registered in apache error_log before segfault) Reproduce code: --------------- $dirs = new DirectoryIterator( 'dir' ); foreach( $dirs as $entry ) { if($dirs->isDir($entry) && !$dirs->isDot($entry)){ $list[] = $entry; } } Expected result: ---------------- code executed correctly. Actual result: -------------- notice] child pid 16011 exit signal Segmentation fault (11) can't get a backtrace :-( ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35567&edit=1

« previous php.bugs (#89813) next »