php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39717 bogus, ignore
Submitted: 2006-12-02 23:16 UTC Modified: 2006-12-02 23:25 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: cpriest at warpmail dot net Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 5.2.0 OS: Apache 2.0.55
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cpriest at warpmail dot net
New email:
PHP Version: OS:

 

 [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?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-02 23:18 UTC] 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:25 UTC] cpriest at warpmail dot net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 23:01:34 2024 UTC