Bug #67187 [NEW]: Crash on interating file system when directory present
| From: | ignesia at gmail dot com | Date: | Sat, 03 May 2014 10:31:23 +0000 |
| Subject: | Bug #67187 [NEW]: Crash on interating file system when directory present | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-185597@lists.php.net to get a copy of this message | ||
From: ignesia at gmail dot com
Operating system: Ubuntu
PHP version: 5.4.28
Package: *Directory/Filesystem functions
Bug Type: Bug
Bug description:Crash on interating file system when directory present
Description:
------------
PHP crashes from "too many files open" when there is a minimum of 1
directory present.
ulimit -n = 1024
Test script:
---------------
function recursiveDirectoryIterator($directory = null, $files = array())
{
$directory = realpath('.') . DIRECTORY_SEPARATOR . 'content' .
DIRECTORY_SEPARATOR;
$iterator = new DirectoryIterator($directory);
foreach ($iterator as $info) {
if ($info->isFile ()) {
$files[$info->__toString ()] = $info;
} elseif (!$info->isDot ()) {
$list = array($info->__toString () =>
recursiveDirectoryIterator(
$directory.DIRECTORY_SEPARATOR.$info->__toString
()
));
if(!empty($files))
$files = array_merge_recursive($files, $filest);
else {
$files = $list;
}
}
}
return $files;
}
Expected result:
----------------
List all directories and files into an array recursively.
Actual result:
--------------
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with
message
'DirectoryIterator::__construct(/home/httpd/public_html/docs/content/):
failed to open dir: Too many open files' in
/home/httpd/public_html/docs/index.php:65\nStack trace:\n#0
/home/httpd/public_html/docs/index.php(65):
DirectoryIterator->__construct('/home/httpd/pub...')\n#1
/home/httpd/public_html/docs/index.php(73):
recursiveDirectoryIterator('/home/httpd/pub...')\n#2
/home/httpd/public_html/docs/index.php(73):
recursiveDirectoryIterator('/home/httpd/pub...')\n#3
/home/httpd/public_html/docs/index.php(73):
recursiveDirectoryIterator('/home/httpd/pub...')\n#4
/home/httpd/public_html/docs/index.php(73):
recursiveDirectoryIterator('/home/httpd/pub...')\n#5
/home/httpd/public_html/docs/index.php(73):
recursiveDirectoryIterator('/home/httpd/pub...')\n#6
/home/httpd/public_html/docs/index.php(73):
recursiveDirectoryIterator('/home/httpd/pub...')\n#7
/home/httpd/public_html/docs/index.php(73):
recursiveDirectoryIterator('/home/httpd/p in
/home/httpd/public_html/docs/index.php on line 65
--
Edit bug report at https://bugs.php.net/bug.php?id=67187&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67187&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67187&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67187&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67187&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67187&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67187&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67187&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67187&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67187&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67187&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67187&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67187&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67187&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67187&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67187&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67187&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67187&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67187&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67187&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67187&r=mysqlcfg