From: davek at gamehouse dot com
Operating system: solaris 11
PHP version: 5.3.23
Package: Apache2 related
Bug Type: Bug
Bug description:die or exit on solaris leaves open file descriptors
Description:
------------
apache 2.4.3 : mod_prefork, keepAlive = Off
php 5.3.23 : ../php-5.3.23/configure'
'--prefix=/opt/ghc/services/php/php5.3.23'
'--with-apxs2=/opt/ghc/services/apache/apache2.4.3-php/bin/apxs'
'--with-config-
file-path=/opt/ghc/services/php/php5.3.23/lib' '--disable-all'
phpinfo.php:
<?php
phpinfo();
die();
Test script:
---------------
server> ./bin/httpd -X &
server> pfiles $(pgrep httpd) |awk '{print $1}' |grep ^[[:digit:]] |wc -l
12
server> pfiles $(pgrep httpd)
25087: ./bin/httpd -X -f /opt/ghc/conf/php_conf/conf/httpd.conf
Current rlimit: 1024 file descriptors
0: S_IFCHR mode:0620 dev:533,11 ino:920560006 uid:0 gid:7 rdev:6,1
O_RDWR|O_NOCTTY|O_LARGEFILE
/dev/pts/1
offset:320891
1: S_IFCHR mode:0620 dev:533,11 ino:920560006 uid:0 gid:7 rdev:6,1
O_RDWR|O_NOCTTY|O_LARGEFILE
/dev/pts/1
offset:320891
2: S_IFREG mode:0644 dev:90,65567 ino:99347 uid:0 gid:0 size:5322
O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE
/opt/ghc/conf/php_conf/logs/error_log
offset:5322
3: S_IFSOCK mode:0666 dev:540,0 ino:10 uid:0 gid:0 size:0
O_RDWR FD_CLOEXEC
SOCK_STREAM
SO_REUSEADDR,SO_KEEPALIVE,SO_SNDBUF(49152),SO_RCVBUF(128000)
sockname: AF_INET 192.168.27.57 port: 80
4: S_IFDOOR mode:0444 dev:542,0 ino:90 uid:0 gid:0 size:0
O_RDONLY|O_LARGEFILE FD_CLOEXEC door to nscd[9126]
/var/run/name_service_door
5: S_IFIFO mode:0000 dev:530,0 ino:21648220 uid:0 gid:0 size:0
O_RDWR|O_NONBLOCK FD_CLOEXEC
6: S_IFIFO mode:0000 dev:530,0 ino:21648220 uid:0 gid:0 size:0
O_RDWR FD_CLOEXEC
7: S_IFREG mode:0644 dev:90,65567 ino:97687 uid:0 gid:0 size:0
O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE FD_CLOEXEC
/opt/ghc/conf/php_conf/logs/access_log
offset:0
8: S_IFIFO mode:0000 dev:530,0 ino:21648221 uid:0 gid:0 size:0
O_RDWR FD_CLOEXEC
9: S_IFPORT mode:0000 dev:543,0 uid:103 gid:1 size:0
10: S_IFIFO mode:0000 dev:530,0 ino:21648222 uid:0 gid:0 size:0
O_RDWR
client> curl http://server/phpinfo.php
server> pfiles $(pgrep httpd) |awk '{print $1}' |grep ^[[:digit:]] |wc -l
13
server> pfiles $(pgrep httpd)
25087: ./bin/httpd -X -f /opt/ghc/conf/php_conf/conf/httpd.conf
Current rlimit: 1024 file descriptors
0: S_IFCHR mode:0620 dev:533,11 ino:920560006 uid:0 gid:7 rdev:6,1
O_RDWR|O_NOCTTY|O_LARGEFILE
/dev/pts/1
offset:324283
1: S_IFCHR mode:0620 dev:533,11 ino:920560006 uid:0 gid:7 rdev:6,1
O_RDWR|O_NOCTTY|O_LARGEFILE
/dev/pts/1
offset:324283
2: S_IFREG mode:0644 dev:90,65567 ino:99347 uid:0 gid:0 size:5322
O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE
/opt/ghc/conf/php_conf/logs/error_log
offset:5322
3: S_IFSOCK mode:0666 dev:540,0 ino:10 uid:0 gid:0 size:0
O_RDWR FD_CLOEXEC
SOCK_STREAM
SO_REUSEADDR,SO_KEEPALIVE,SO_SNDBUF(49152),SO_RCVBUF(128000)
sockname: AF_INET 192.168.27.57 port: 80
4: S_IFDOOR mode:0444 dev:542,0 ino:90 uid:0 gid:0 size:0
O_RDONLY|O_LARGEFILE FD_CLOEXEC door to nscd[9126]
/var/run/name_service_door
5: S_IFIFO mode:0000 dev:530,0 ino:21648220 uid:0 gid:0 size:0
O_RDWR|O_NONBLOCK FD_CLOEXEC
6: S_IFIFO mode:0000 dev:530,0 ino:21648220 uid:0 gid:0 size:0
O_RDWR FD_CLOEXEC
7: S_IFREG mode:0644 dev:90,65567 ino:97687 uid:0 gid:0 size:0
O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE FD_CLOEXEC
/opt/ghc/conf/php_conf/logs/access_log
offset:0
8: S_IFIFO mode:0000 dev:530,0 ino:21648221 uid:0 gid:0 size:0
O_RDWR FD_CLOEXEC
9: S_IFPORT mode:0000 dev:543,0 uid:103 gid:1 size:0
10: S_IFIFO mode:0000 dev:530,0 ino:21648222 uid:0 gid:0 size:0
O_RDWR
13: S_IFDIR mode:0755 dev:90,65567 ino:21918 uid:0 gid:0 size:22
O_RDONLY
/opt/ghc/services/apache/apache2.4.3-php
offset:0
client> curl http://server/phpinfo.php
server> pfiles $(pgrep httpd) |awk '{print $1}' |grep ^[[:digit:]] |wc -l
14
server> pfiles $(pgrep httpd)
25087: ./bin/httpd -X -f /opt/ghc/conf/php_conf/conf/httpd.conf
Current rlimit: 1024 file descriptors
0: S_IFCHR mode:0620 dev:533,11 ino:920560006 uid:0 gid:7 rdev:6,1
O_RDWR|O_NOCTTY|O_LARGEFILE
/dev/pts/1
offset:327991
1: S_IFCHR mode:0620 dev:533,11 ino:920560006 uid:0 gid:7 rdev:6,1
O_RDWR|O_NOCTTY|O_LARGEFILE
/dev/pts/1
offset:327991
2: S_IFREG mode:0644 dev:90,65567 ino:99347 uid:0 gid:0 size:5322
O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE
/opt/ghc/conf/php_conf/logs/error_log
offset:5322
3: S_IFSOCK mode:0666 dev:540,0 ino:10 uid:0 gid:0 size:0
O_RDWR FD_CLOEXEC
SOCK_STREAM
SO_REUSEADDR,SO_KEEPALIVE,SO_SNDBUF(49152),SO_RCVBUF(128000)
sockname: AF_INET 192.168.27.57 port: 80
4: S_IFDOOR mode:0444 dev:542,0 ino:90 uid:0 gid:0 size:0
O_RDONLY|O_LARGEFILE FD_CLOEXEC door to nscd[9126]
/var/run/name_service_door
5: S_IFIFO mode:0000 dev:530,0 ino:21648220 uid:0 gid:0 size:0
O_RDWR|O_NONBLOCK FD_CLOEXEC
6: S_IFIFO mode:0000 dev:530,0 ino:21648220 uid:0 gid:0 size:0
O_RDWR FD_CLOEXEC
7: S_IFREG mode:0644 dev:90,65567 ino:97687 uid:0 gid:0 size:0
O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE FD_CLOEXEC
/opt/ghc/conf/php_conf/logs/access_log
offset:0
8: S_IFIFO mode:0000 dev:530,0 ino:21648221 uid:0 gid:0 size:0
O_RDWR FD_CLOEXEC
9: S_IFPORT mode:0000 dev:543,0 uid:103 gid:1 size:0
10: S_IFIFO mode:0000 dev:530,0 ino:21648222 uid:0 gid:0 size:0
O_RDWR
13: S_IFDIR mode:0755 dev:90,65567 ino:21918 uid:0 gid:0 size:22
O_RDONLY
/opt/ghc/services/apache/apache2.4.3-php
offset:0
14: S_IFDIR mode:0755 dev:90,65567 ino:17614 uid:103 gid:1 size:20
O_RDONLY
/opt/ghc/webroots/php_content
offset:0
Expected result:
----------------
I'd expect that FD's don't leak.
Actual result:
--------------
every call adds another open FD.
I've traced this to main/main.c 2266
PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
{
...
...
> old_cwd_fd = open(".", 0);
...
VCWD_CHDIR_FILE(primary_file->filename);
...
...
zend_try {
...
retval = (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 3,
prepend_file_p,
primary_file, append_file_p) == SUCCESS);
} zend_end_try()
...
...
// close old_cwd_fd code
}
-- looks to me that the objective is to move the process into the directory
of
the script. I thought that moving the close of the FD to right after the
move
[VCWD-CHDIR_FILE()] would cleanup the open FD and it does, However why is
this
happening in the first place? I ran the same test on my OSX workstation
and
FD's don't accumulate.
--
Edit bug report at https://bugs.php.net/bug.php?id=64577&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=64577&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=64577&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=64577&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64577&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64577&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64577&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64577&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64577&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64577&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64577&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64577&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64577&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64577&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64577&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64577&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64577&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64577&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64577&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64577&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64577&r=mysqlcfg