#34415 [Com]: seg fault when using scandir
ID: 34415 Comment by: aarondoom at cookiedoom dot com Reported By: worthbob01 at yahoo dot com Status: No Feedback Bug Type: Reproducible crash Operating System: RHES3 PHP Version: 5CVS-2005-09-09 (snap) New Comment: Your function is stuck in a recursive loop, eventually this will seg fault. If you wanna see it in action add the following lines to the top of the function. static $depth = 0; echo $depth++; To fix the problem remove the . \\ from the tail of scandir_recursive($directory.$folderItem.\\);. Here's a cleaned up function to not display errors and so forth. function scandir_recursive($directory) { $folderContents = array(); $directory = realpath($directory) . DIRECTORY_SEPARATOR; $folderItems = @scandir($directory); if (!is_array($folderItems)) return No access; foreach ($folderItems as $folderItem) { if (substr($folderItem, 0, 1) != .) { // Ignore anything hidden if (is_dir($directory . $folderItem . DIRECTORY_SEPARATOR)) $folderContents[$folderItem] = scandir_recursive($directory . $folderItem); else $folderContents[] = $folderItem; } } return $folderContents; } ^_^ Previous Comments: [2005-09-18 01:00:02] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to Open. [2005-09-10 23:21:24] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a backtrace to see what is happening behind the scenes. To find out how to generate a backtrace, please read http://bugs.php.net/bugs-generating-backtrace.php Once you have generated a backtrace, please submit it to this bug report and change the status back to Open. Thank you for helping us make PHP better. [2005-09-10 17:04:50] worthbob01 at yahoo dot com [EMAIL PROTECTED] design]# date; php --version; php sample.php ; date Sat Sep 10 10:02:20 CDT 2005 PHP 5.1.0-dev (cli) (built: Sep 9 2005 12:59:00) Copyright (c) 1997-2005 The PHP Group Zend Engine v2.1.0-dev, Copyright (c) 1998-2005 Zend Technologies Segmentation fault Sat Sep 10 10:02:21 CDT 2005 [2005-09-07 23:43:42] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip [2005-09-07 23:13:41] worthbob01 at yahoo dot com Description: recursive scandir causes seg fault. code example from http://us2.php.net/scandir User Contributed Notes. Reproduce code: --- ?php $afiles = scandir_recursive(/tmp); function scandir_recursive($directory) { $folderContents = array(); $directory = realpath($directory).DIRECTORY_SEPARATOR; foreach (scandir($directory) as $folderItem) { if ($folderItem != . AND $folderItem != ..) { if (is_dir($directory.$folderItem.DIRECTORY_SEPARATOR)) { $folderContents[$folderItem] = scandir_recursive( $directory.$folderItem.\\); } else { $folderContents[] = $folderItem; } } } return $folderContents; } ? Expected result: nothing as there is not output in the sample. just expected it to run without a seg fault. Actual result: -- [EMAIL PROTECTED] design]# date;php sample.php;date Wed Sep 7 16:11:11 CDT 2005 Segmentation fault Wed Sep 7 16:11:12 CDT 2005 [EMAIL PROTECTED] design]# -- Edit this bug report at http://bugs.php.net/?id=34415edit=1
#33579 [Bgs]: Functions not usable when require()'d from parent later in a child.
ID: 33579 User updated by: aarondoom at cookiedoom dot com Reported By: aarondoom at cookiedoom dot com Status: Bogus Bug Type: Scripting Engine problem Operating System: Gentoo Linux 1.6.12 PHP Version: 4.4.0 New Comment: Thank you for clarifying that. Your answer is acceptable. Previous Comments: [2005-07-06 07:22:36] [EMAIL PROTECTED] Do you understand that require_once/include_once does exactly the same as these define checks you are using to prevent multiple exclusion? In your particular example you are doing a conditional function definition (since it is inside an if clause) which means the function needs to be defined at runtime and cannot be added at compile-time. This usually shouldn't matter, but you are trying to call the function before you define it. In Funcs.inc you require DB.inc which calls Bleh() and then after that require you define the Bleh() function. This simply won't work, and it isn't a bug. If you are doing to do conditional function definitions, you *must* define your functions before you try to call them. So yes, we understand perfectly what is going on. If you look at the bug number for this bug, you might notice that this is number 33579. That's a lot of bugs. We really can't take the time to explain each one like this. If we say something isn't a bug, 99.9% of the time, it isn't. The occasional one slips through, of course, but in most cases, including this one, it is simple user error that is better explained on one of the many support lists. [2005-07-06 03:04:52] aarondoom at cookiedoom dot com It is obvious you have no idea what is going on and the reason they need to be there. I may from one page load one include instead of another. I'm not going to use ugly stupid code when there are hundreds of files to update merely to work around this bug. There is a problem here and it is within the PHP engine. I'm sorry that you do not wish to fix it. I sincerely hope you people are more helpful to others. Thanks anyway for not looking into the issue. [2005-07-06 01:51:31] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Try nuke those stupid define()'s and use require_once() instead.. [2005-07-06 01:42:27] aarondoom at cookiedoom dot com Here's an update to the code, this reproduces the Bug. ?php // Test.php require(Header.inc); Bleh(); ? ?php // Header.inc require(Funcs.inc); require(Emails.inc); Bleh(); // Won't error ? ?php // Funcs.inc if (!defined(_FUNCS_INC_)) { define(_FUNCS_INC_, true); require(DB.inc); function Bleh() { printf(Blah\n); } } // _FUNCS_INC_ ? ?php // Emails.inc if (!defined(_EMAILS_INC_)) { define(_EMAILS_INC_, true); require(DB.inc); } // _EMAILS_INC_ ? ?php // DB.inc if (!defined(_DB_INC_)) { define(_DB_INC_, true); require(Funcs.inc); Bleh(); } // _DB_INC_ ? [2005-07-06 01:30:39] aarondoom at cookiedoom dot com http://wwwtest.amberalert911.net/debug.php debug.php includes funcs.inc funcs.inc includes emails.inc global.inc emails.inc includes db.inc funcs.inc forms.inc MailServer.inc db.inc includes funcs.inc global.inc forms.inc includes db.inc As you can see, it's not working as you defined. If this is not a bug with PHP, perhaps it's a bug in Apache? I was able to execute my example via the command line PHP, but not the debug.php via the command line. Not sure what the difference really is. The example is much simpler of course. All of the listed files are quite large, no smaller than 200 lines each so I'm not going to post them here, but look at the URI listed above. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/33579 -- Edit this bug report at http://bugs.php.net/?id=33579edit=1
#33579 [NEW]: Functions not usable when require'd from parent later in a child.
From: aarondoom at cookiedoom dot com Operating system: Gentoo Linux 1.6.12 PHP version: 4.3.11 PHP Bug Type: Unknown/Other Function Bug description: Functions not usable when require'd from parent later in a child. Description: When a parent document requires a source file and then requires a second file that requires the same as above it cannot access the functions in the already required file from the parent, but cannot use or redefine the functions that are required. Using code that if (!defined(_FUNCS_INC_)) { define(_FUNCS_INC_, true); function Bleh($Bloop) { return $Bloop; } } // _FUNCS_INC_. This is a problem because the _FUNCS_INC_ is defined as well as the functions defined inside of the scope of the document though function_exists will return false and calling the function will obviously fail for that reason, I cannot redefine those functions in the sub-document or I'll get Cannot redefine function bleh... even though I can't use it. Though it is easy enough to work around the issue (With the if (!defined()) stuff require_once doesn't even make it work BTW) I'm reorganizing several hundred files, at least 1/3 of which are includes which need to be re-ordered. Any help would be greatly appreciated. Reproduce code: --- ?php // Funcs.inc if (!defined(_FUNCS_INC_)) { define(_FUNCS_INC_, true); function Bleh() { printf(Blah\n); } } // _FUNCS_INC_ ? ?php // DB.inc require(Funcs.inc); Bleh(); ? ?php // Header.inc require(Funcs.inc); require(DB.inc); Bleh(); // Won't error ? Expected result: Blah\n Blah\n Actual result: -- Fatal error: Call to undefined function: bleh() in /var/www/localhost/includes/DB.inc on line 3 -- Edit bug report at http://bugs.php.net/?id=33579edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33579r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33579r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33579r=trysnapshot51 Fixed in CVS:http://bugs.php.net/fix.php?id=33579r=fixedcvs Fixed in release:http://bugs.php.net/fix.php?id=33579r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33579r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33579r=needscript Try newer version: http://bugs.php.net/fix.php?id=33579r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33579r=support Expected behavior: http://bugs.php.net/fix.php?id=33579r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33579r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33579r=submittedtwice register_globals:http://bugs.php.net/fix.php?id=33579r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33579r=php3 Daylight Savings:http://bugs.php.net/fix.php?id=33579r=dst IIS Stability: http://bugs.php.net/fix.php?id=33579r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33579r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33579r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33579r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33579r=mysqlcfg
#33579 [Bgs-Opn]: Functions not usable when require'd from parent later in a child.
ID: 33579 User updated by: aarondoom at cookiedoom dot com Reported By: aarondoom at cookiedoom dot com -Status: Bogus +Status: Open Bug Type: Unknown/Other Function Operating System: Gentoo Linux 1.6.12 -PHP Version: 4.3.11 +PHP Version: 4.4.0 New Comment: http://wwwtest.amberalert911.net/debug.php debug.php includes funcs.inc funcs.inc includes emails.inc global.inc emails.inc includes db.inc funcs.inc forms.inc MailServer.inc db.inc includes funcs.inc global.inc forms.inc includes db.inc As you can see, it's not working as you defined. If this is not a bug with PHP, perhaps it's a bug in Apache? I was able to execute my example via the command line PHP, but not the debug.php via the command line. Not sure what the difference really is. The example is much simpler of course. All of the listed files are quite large, no smaller than 200 lines each so I'm not going to post them here, but look at the URI listed above. Previous Comments: [2005-07-06 00:42:33] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Works just fine with all versions I can test right now (4.3, 4.4, 5.0, 5.1 etc.). [2005-07-05 23:37:44] aarondoom at cookiedoom dot com Description: When a parent document requires a source file and then requires a second file that requires the same as above it cannot access the functions in the already required file from the parent, but cannot use or redefine the functions that are required. Using code that if (!defined(_FUNCS_INC_)) { define(_FUNCS_INC_, true); function Bleh($Bloop) { return $Bloop; } } // _FUNCS_INC_. This is a problem because the _FUNCS_INC_ is defined as well as the functions defined inside of the scope of the document though function_exists will return false and calling the function will obviously fail for that reason, I cannot redefine those functions in the sub-document or I'll get Cannot redefine function bleh... even though I can't use it. Though it is easy enough to work around the issue (With the if (!defined()) stuff require_once doesn't even make it work BTW) I'm reorganizing several hundred files, at least 1/3 of which are includes which need to be re-ordered. Any help would be greatly appreciated. Reproduce code: --- ?php // Funcs.inc if (!defined(_FUNCS_INC_)) { define(_FUNCS_INC_, true); function Bleh() { printf(Blah\n); } } // _FUNCS_INC_ ? ?php // DB.inc require(Funcs.inc); Bleh(); ? ?php // Header.inc require(Funcs.inc); require(DB.inc); Bleh(); // Won't error ? Expected result: Blah\n Blah\n Actual result: -- Fatal error: Call to undefined function: bleh() in /var/www/localhost/includes/DB.inc on line 3 -- Edit this bug report at http://bugs.php.net/?id=33579edit=1
#33579 [Opn]: Functions not usable when require'd from parent later in a child.
ID: 33579 User updated by: aarondoom at cookiedoom dot com Reported By: aarondoom at cookiedoom dot com Status: Open Bug Type: Unknown/Other Function Operating System: Gentoo Linux 1.6.12 PHP Version: 4.4.0 New Comment: Here's an update to the code, this reproduces the Bug. ?php // Test.php require(Header.inc); Bleh(); ? ?php // Header.inc require(Funcs.inc); require(Emails.inc); Bleh(); // Won't error ? ?php // Funcs.inc if (!defined(_FUNCS_INC_)) { define(_FUNCS_INC_, true); require(DB.inc); function Bleh() { printf(Blah\n); } } // _FUNCS_INC_ ? ?php // Emails.inc if (!defined(_EMAILS_INC_)) { define(_EMAILS_INC_, true); require(DB.inc); } // _EMAILS_INC_ ? ?php // DB.inc if (!defined(_DB_INC_)) { define(_DB_INC_, true); require(Funcs.inc); Bleh(); } // _DB_INC_ ? Previous Comments: [2005-07-06 01:30:39] aarondoom at cookiedoom dot com http://wwwtest.amberalert911.net/debug.php debug.php includes funcs.inc funcs.inc includes emails.inc global.inc emails.inc includes db.inc funcs.inc forms.inc MailServer.inc db.inc includes funcs.inc global.inc forms.inc includes db.inc As you can see, it's not working as you defined. If this is not a bug with PHP, perhaps it's a bug in Apache? I was able to execute my example via the command line PHP, but not the debug.php via the command line. Not sure what the difference really is. The example is much simpler of course. All of the listed files are quite large, no smaller than 200 lines each so I'm not going to post them here, but look at the URI listed above. [2005-07-06 00:42:33] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Works just fine with all versions I can test right now (4.3, 4.4, 5.0, 5.1 etc.). [2005-07-05 23:37:44] aarondoom at cookiedoom dot com Description: When a parent document requires a source file and then requires a second file that requires the same as above it cannot access the functions in the already required file from the parent, but cannot use or redefine the functions that are required. Using code that if (!defined(_FUNCS_INC_)) { define(_FUNCS_INC_, true); function Bleh($Bloop) { return $Bloop; } } // _FUNCS_INC_. This is a problem because the _FUNCS_INC_ is defined as well as the functions defined inside of the scope of the document though function_exists will return false and calling the function will obviously fail for that reason, I cannot redefine those functions in the sub-document or I'll get Cannot redefine function bleh... even though I can't use it. Though it is easy enough to work around the issue (With the if (!defined()) stuff require_once doesn't even make it work BTW) I'm reorganizing several hundred files, at least 1/3 of which are includes which need to be re-ordered. Any help would be greatly appreciated. Reproduce code: --- ?php // Funcs.inc if (!defined(_FUNCS_INC_)) { define(_FUNCS_INC_, true); function Bleh() { printf(Blah\n); } } // _FUNCS_INC_ ? ?php // DB.inc require(Funcs.inc); Bleh(); ? ?php // Header.inc require(Funcs.inc); require(DB.inc); Bleh(); // Won't error ? Expected result: Blah\n Blah\n Actual result: -- Fatal error: Call to undefined function: bleh() in /var/www/localhost/includes/DB.inc on line 3 -- Edit this bug report at http://bugs.php.net/?id=33579edit=1
#33579 [Bgs-Csd]: Functions not usable when require()'d from parent later in a child.
ID: 33579 User updated by: aarondoom at cookiedoom dot com Reported By: aarondoom at cookiedoom dot com -Status: Bogus +Status: Closed Bug Type: Scripting Engine problem Operating System: Gentoo Linux 1.6.12 PHP Version: 4.4.0 New Comment: It is obvious you have no idea what is going on and the reason they need to be there. I may from one page load one include instead of another. I'm not going to use ugly stupid code when there are hundreds of files to update merely to work around this bug. There is a problem here and it is within the PHP engine. I'm sorry that you do not wish to fix it. I sincerely hope you people are more helpful to others. Thanks anyway for not looking into the issue. Previous Comments: [2005-07-06 01:51:31] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Try nuke those stupid define()'s and use require_once() instead.. [2005-07-06 01:42:27] aarondoom at cookiedoom dot com Here's an update to the code, this reproduces the Bug. ?php // Test.php require(Header.inc); Bleh(); ? ?php // Header.inc require(Funcs.inc); require(Emails.inc); Bleh(); // Won't error ? ?php // Funcs.inc if (!defined(_FUNCS_INC_)) { define(_FUNCS_INC_, true); require(DB.inc); function Bleh() { printf(Blah\n); } } // _FUNCS_INC_ ? ?php // Emails.inc if (!defined(_EMAILS_INC_)) { define(_EMAILS_INC_, true); require(DB.inc); } // _EMAILS_INC_ ? ?php // DB.inc if (!defined(_DB_INC_)) { define(_DB_INC_, true); require(Funcs.inc); Bleh(); } // _DB_INC_ ? [2005-07-06 01:30:39] aarondoom at cookiedoom dot com http://wwwtest.amberalert911.net/debug.php debug.php includes funcs.inc funcs.inc includes emails.inc global.inc emails.inc includes db.inc funcs.inc forms.inc MailServer.inc db.inc includes funcs.inc global.inc forms.inc includes db.inc As you can see, it's not working as you defined. If this is not a bug with PHP, perhaps it's a bug in Apache? I was able to execute my example via the command line PHP, but not the debug.php via the command line. Not sure what the difference really is. The example is much simpler of course. All of the listed files are quite large, no smaller than 200 lines each so I'm not going to post them here, but look at the URI listed above. [2005-07-06 00:42:33] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Works just fine with all versions I can test right now (4.3, 4.4, 5.0, 5.1 etc.). [2005-07-05 23:37:44] aarondoom at cookiedoom dot com Description: When a parent document requires a source file and then requires a second file that requires the same as above it cannot access the functions in the already required file from the parent, but cannot use or redefine the functions that are required. Using code that if (!defined(_FUNCS_INC_)) { define(_FUNCS_INC_, true); function Bleh($Bloop) { return $Bloop; } } // _FUNCS_INC_. This is a problem because the _FUNCS_INC_ is defined as well as the functions defined inside of the scope of the document though function_exists will return false and calling the function will obviously fail for that reason, I cannot redefine those functions in the sub-document or I'll get Cannot redefine function bleh... even though I can't use it. Though it is easy enough to work around the issue (With the if (!defined()) stuff require_once doesn't even make it work BTW) I'm reorganizing several hundred files, at least 1/3 of which are includes which need to be re-ordered. Any help would be greatly appreciated. Reproduce code: --- ?php // Funcs.inc if (!defined(_FUNCS_INC_)) { define(_FUNCS_INC_, true); function Bleh() { printf(Blah\n); } } // _FUNCS_INC_ ? ?php // DB.inc require(Funcs.inc); Bleh(); ? ?php // Header.inc require(Funcs.inc