#39717 [Opn]: opendir - Segmentation Fault - Reproducable

From: Date: Sat, 02 Dec 2006 23:18:18 +0000
Subject: #39717 [Opn]: opendir - Segmentation Fault - Reproducable
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-105805@lists.php.net to get a copy of this message
ID: 39717 User updated by: cpriest at warpmail dot net Reported By: cpriest at warpmail dot net Status: Open Bug Type: Reproducible crash Operating System: Apache 2.0.55 PHP Version: 5.2.0 New Comment: Easier to read code: function LocateImportFiles($Path) { $tFilepaths = array(); if(($hDir = opendir($Path)) !== false) { while(($filepath = readdir($hDir)) !== false) { echo $filepath.'<BR>'; flush(); if(is_dir($filepath)) $tFilepaths = array_merge($tFilepaths, LocateImportFiles($filepath)); else { switch(array_pop(explode('.',$filepath))) { case 'htm': case 'html': $tFilepaths[$filepath] = 'Html Creative'; break; case 'txt': if(strstr($filepath, 'Subjects') !== false) $tFilepaths[$filepath] = 'Subject Lines'; else $tFilepaths[$filepath] = 'Unknown (Ignore)'; break; case 'zip': UnzipFile($filepath, dirname($filepath), $OutputDir, false); $tFilepaths = array_merge($tFilepaths, LocateImportFiles($OutputDir)); break; } } } closedir($hDir); } return $tFilepaths; } Previous Comments: ------------------------------------------------------------------------ [2006-12-02 23:16:52] cpriest at warpmail dot net Description: ------------ I am getting segmentation faults while using opendir(). This has been going off and on with glob() and opendir() over the course of many versions. I've never really thought it was with php but the segmentation faults only occur while using nearly any of the directory based functions in php from versions 5.0.x through 5.2.x Reproduce code: --------------- function LocateImportFiles($Path) { $tFilepaths = array(); if(($hDir = opendir($Path)) !== false) { while(($filepath = readdir($hDir)) !== false) { echo $filepath.'<BR>'; flush(); if(is_dir($filepath)) $tFilepaths = array_merge($tFilepaths, LocateImportFiles($filepath)); else { switch(array_pop(explode('.',$filepath))) { case 'htm': case 'html': $tFilepaths[$filepath] = 'Html Creative'; break; case 'txt': if(strstr($filepath, 'Subjects') !== false) $tFilepaths[$filepath] = 'Subject Lines'; else $tFilepaths[$filepath] = 'Unknown (Ignore)'; break; case 'zip': UnzipFile($filepath, dirname($filepath), $OutputDir, false); $tFilepaths = array_merge($tFilepaths, LocateImportFiles($OutputDir)); break; } } } closedir($hDir); } return $tFilepaths; } Expected result: ---------------- no crashes Actual result: -------------- segmentation fault. Is there any way I can glean any usable information from the segmentation fault I can send you? Invariably this type of problem never seems to be able to be reproduced elsewhere and perhaps I can get you a dump of some file to isolate where the issue is? ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39717&edit=1

« previous php.bugs (#105805) next »