php5 opens /proc/XXX/auxv thousands of times until Apache crashes with "too many open files"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
php5 (Ubuntu) |
Confirmed
|
Medium
|
Unassigned |
Bug Description
Hello,
PHP5, or rather "php-cgi", seems to open /proc/$PID/auxv a lot and doesn't close all file descriptors when restarting with "apachectl graceful", until eventually, the system runs out of file descriptors.
After about four weeks of uptime my Linux box (Ubuntu 12.04.1) had over 90'000 opened files, almost all of them were the above. Then Apache refused "apachectl graceful" because Linux could not open all files any more.
After restarting Apache, all files were closed again. Now, the file descriptors are leaking again - much more slowly because my cron scripts use "apachectl restart" now instead of "apachectl graceful", but still. After two weeks, I have roughly 15'000 opened files, of which 8'000 are /proc/$PID/auxv.
I think this is quite a serious bug since it makes the system grind to a halt eventually.
Thank you for investigating!
Regards,
Jens
PS: "lsof" shows it like this:
php-cgi 32268 sdm 77r REG 0,3 0 690669699 /proc/20964/auxv
php-cgi 32268 sdm 78r REG 0,3 0 690669699 /proc/20964/auxv
php-cgi 32268 sdm 79r REG 0,3 0 690669699 /proc/20964/auxv
php-cgi 32268 sdm 80r REG 0,3 0 690669699 /proc/20964/auxv
...
php-cgi 32268 sdm 281r REG 0,3 0 690669699 /proc/20964/auxv
for each php-cgi process. 20964 is the "apache2" main process.
ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: php5 5.3.10-1ubuntu3.2
ProcVersionSign
Uname: Linux 3.2.0-24-generic x86_64
ApportVersion: 2.0.1-0ubuntu8
Architecture: amd64
Date: Wed Jul 11 22:13:27 2012
PackageArchitec
ProcEnviron:
TERM=xterm-color
PATH=(custom, no user)
LANG=de_DE.UTF-8
SHELL=/bin/bash
SourcePackage: php5
UpgradeStatus: Upgraded to precise on 2012-05-04 (68 days ago)
Hi Jens, thanks for taking the time to file a bug report. I'm having trouble reproducing this issue. When I install apache2 and php5-cgi and copy a simple php file to /usr/lib/cgi-bin, I don't get any opening of /proc files at all. This is the list I see when cgi is forked (the parent process doesn't open any new files on requests):
[pid 30702] open("/ usr/local/ lib/tls/ x86_64/ libcrypt. so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/local/ lib/tls/ libcrypt. so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/local/ lib/x86_ 64/libcrypt. so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/local/ lib/libcrypt. so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/lib/ tls/x86_ 64/libcrypt. so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/lib/ tls/libcrypt. so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/lib/ x86_64/ libcrypt. so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/lib/ libcrypt. so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) etc/ld. so.cache" , O_RDONLY|O_CLOEXEC) = 3 lib/x86_ 64-linux- gnu/libcrypt. so.1", O_RDONLY|O_CLOEXEC) = 3 usr/local/ lib/libz. so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/lib/ libz.so. 1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) lib/x86_ 64-linux- gnu/libz. so.1", O_RDONLY|O_CLOEXEC) = 3 usr/local/ lib/libresolv. so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/lib/ libresolv. so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) lib/x86_ 64-linux- gnu/libresolv. so.2", O_RDONLY|O_CLOEXEC) = 3 usr/local/ lib/libdb- 5.1.so" , O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/lib/ libdb-5. 1.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/lib/ x86_64- linux-gnu/ libdb-5. 1.so", O_RDONLY|O_CLOEXEC) = 3 usr/local/ lib/libbz2. so.1.0" , O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/lib/ libbz2. so.1.0" , O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) lib/x86_ 64-linux- gnu/libbz2. so.1.0" , O_RDONLY|O_CLOEXEC) = 3 usr/local/ lib/libpcre. so.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/lib/ libpcre. so.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) lib/x86_ 64-linux- gnu/libpcre. so.3", O_RDONLY|O_CLOEXEC) = 3 usr/local/ lib/libm. so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) usr/lib/ libm.so. 6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) lib/x86_ 64-linux- gnu/libm. so.6", O_RDONLY|O_CLOEXEC) = 3 usr/local/ lib/libdl. so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directo...
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/
[pid 30702] open("/