php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45133 too many open files
Submitted: 2008-05-30 02:09 UTC Modified: 2008-07-19 01:00 UTC
Votes:10
Avg. Score:4.5 ± 0.8
Reproduced:7 of 8 (87.5%)
Same Version:4 (57.1%)
Same OS:2 (28.6%)
From: mckinneyseller at yahoo dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.2.6 OS: Centos
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mckinneyseller at yahoo dot com
New email:
PHP Version: OS:

 

 [2008-05-30 02:09 UTC] mckinneyseller at yahoo dot com
Description:
------------
'./configure' '--build=i686-redhat-linux-gnu' '--host=i686-redhat-linux-gnu' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--without-mime-magic' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter' '--disable-json' '--with-mcrypt=/usr/local' '--with-mhash=/usr/local'

PHP Version 5.2.6
Apache Version 	Apache/2.2.3 (CentOS)
Apache API Version 	20051115 


Reproduce code:
---------------
All includes leave the .php file open.

I am running the magento e-commerce package.

The includes are standard.

This bug was reported as bug #43105 and the change log says it was
fixed for php 5.2.6 and that is what I am running per above phpinfo.


Expected result:
----------------
When I run lsof -u apache | grep magento I do not expect to see any
open .php files.



Actual result:
--------------
I have 1900 open files.  Many are multiple file handles for the same file.  I eventually get "too many open files" error.  Some example output from 
lsof -u apache | grep magento are:

httpd   15777 apache   31r   REG      0,211    28400   82674022 /var/www/vhosts/bubbleyou.com/httpdocs/magento/app/code/core/Mage/Core/Model/App.php
httpd   15777 apache   32r   REG      0,211     3704   82483264 /var/www/vhosts/bubbleyou.com/httpdocs/magento/lib/Varien/Event/Collection.php
httpd   15777 apache   33r   REG      0,211     2587   82483270 /var/www/vhosts/bubbleyou.com/httpdocs/magento/lib/Varien/Event/Observer/Collection.php
httpd   15777 apache   34r   REG      0,211    27056   82673926 /var/www/vhosts/bubbleyou.com/httpdocs/magento/app/code/core/Mage/Core/Model/Config.php
httpd   15777 apache   35r   REG      0,211     1300   82674010 /var/www/vhosts/bubbleyou.com/httpdocs/magento/app/code/core/Mage/Core/Model/Config/Base.php
httpd   15777 apache   36r   REG      0,211    14602   82483250 /var/www/vhosts/bubbleyou.com/httpdocs/magento/lib/Varien/Simplexml/Config.php
httpd   15777 apache   37r   REG      0,211    12798   82673982 /var/www/vhosts/bubbleyou.com/httpdocs/magento/app/code/core/Mage/Core/Model/Locale.php
httpd   15777 apache   38r   REG      0,211     4426   82674014 /var/www/vhosts/bubbleyou.com/httpdocs/magento/app/code/core/Mage/Core/Model/Config/Options.php
httpd   15777 apache   39r   REG      0,211    19181   82483316 /var/www/vhosts/bubbleyou.com/httpdocs/magento/lib/Varien/Object.php


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-30 16:57 UTC] mckinneyseller at yahoo dot com
Here is reproducible source code:
<?php
echo '<br>';
echo 'this is test1.php';
echo '<br>';
echo '<br>now include include1.php';
include ('include1.php');
echo '<br>';
require_once('require1.php');
?>


The lsof output is:
httpd   22255 apache   28r   REG      0,211       63   81173388 /var/www/vhosts/bubbleyou.com/httpdocs/test2.php
httpd   22255 apache   29r   REG      0,211       65   81173382 /var/www/vhosts/bubbleyou.com/httpdocs/include1.php
httpd   22255 apache   30r   REG      0,211      169   81173386 /var/www/vhosts/bubbleyou.com/httpdocs/test1.php
httpd   22255 apache   31r   REG      0,211       65   81173382 /var/www/vhosts/bubbleyou.com/httpdocs/include1.php
httpd   22255 apache   33r   REG      0,211       63   81173388 /var/www/vhosts/bubbleyou.com/httpdocs/test2.php
httpd   22255 apache   34r   REG      0,211       63   81173388 /var/www/vhosts/bubbleyou.com/httpdocs/test2.php
httpd   22255 apache   36r   REG      0,211       65   81173382 /var/www/vhosts/bubbleyou.com/httpdocs/include1.php


And every time I rerun the above code I get more open file handles for these same files.
When I run under PHP 5.2.0, I don't get this result.
 [2008-05-30 17:10 UTC] mckinneyseller at yahoo dot com
I did another test.  It is only the include that keeps the file handle open.  If I change to be include_once, it does not happen.

Unfortunately the magento ecommerce package uses include and there are thousands of files that would have to be changed to use include_once instead -- and it would probably break the ecommerce package.

This is a bug in PHP 5.2.6 and was in PHP 5.2.5 too.
 [2008-07-11 16:21 UTC] jani@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2008-07-19 01:00 UTC] 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".
 [2011-09-24 08:52 UTC] gongobot at yandex dot ru
UBUNTU 10.04.3
PHP 5.3.2

for ($i=0; $i < 1000; $i++) include_once('/www/domain.com/config.inc.php');

Warning: include_once(/www/domain.com/config.inc.php): failed to open stream: Too many open files in test.php

lsof -u www-data | wc -l
And I have 7600 open files.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jun 19 17:01:34 2025 UTC