ID: 39717
User updated by: cpriest at warpmail dot net
-Summary: opendir - Segmentation Fault - Reproducable
Reported By: cpriest at warpmail dot net
-Status: Open
+Status: Bogus
Bug Type: Reproducible crash
Operating System: Apache 2.0.55
PHP Version: 5.2.0
New Comment:
Nevermind, this particular time (perhaps every time I've run into
this), I was caught in an infinite loop due to readdir() returning '.'
and '..' entries.
Previous Comments:
------------------------------------------------------------------------
[2006-12-02 23:18:18] cpriest at warpmail dot net
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;
}
------------------------------------------------------------------------
[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