|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-12-02 23:16 UTC] 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?
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 29 15:00:01 2025 UTC |
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; }