#48104 [Com]: PHP FD-Leak - FastCGI + auto_prepend
ID: 48104
Comment by: james at jamesreno dot com
Reported By: james at jamesreno dot com
Status: Open
Bug Type: Unknown/Other Function
Operating System: Debian 5.0.1 (lenny); 2.6.26-2-a
PHP Version: 5.2.9
New Comment:
[*** NOT TESTED - DO NOT USE ***]
After spending countless hours trying to determine where php is leaking
the file descriptors as mentioned in the post. It looks like
zend_destroy_file_handle in Zend/zend_language_scanner.c is missing a
call to zend_file_handle_dtor on file_handler.
If you add zend_file_handle_dtor(file_handle); it would seem the issue
would be fixed.
Is this proper - or is there some reason that zend_destroy_file_handle
does not call the destructor zend_file_handle_dtor????
Previous Comments:
------------------------------------------------------------------------
[2009-04-29 08:18:06] james at jamesreno dot com
strace of the pid is also now included -- i forgot to include it in the
previous pastebin url.
http://pastebin.com/mc72a99b
------------------------------------------------------------------------
[2009-04-29 07:59:49] james at jamesreno dot com
Description:
------------
PHP leaks file descriptors by not closing the requested file at the end
of request.
See: http://pastebin.com/m3edccacf
*** REGARDLESS of suhosin being enabled/compiled or disable and NOT
patched, the same problem appears. I have removed suhosin from php and
yet the issue still appears. Please dont just "blame suhosin" and ignore
this fact.
No third-party modules are enabled - apc has been disabled &
uninstalled as well.
This seems like an off-by-one somewhere in relation to the
auto_prepend.
removing the auto_prepend statement from the php.ini fixes the problem.
Reproduce code:
---------------
Request http://127.0.0.1/somescript.php
auto_prepend_file = "/tmp/test.php";
#/tmp/test.php
<? include("/tmp/test2.php"); ?>
#/tmp/test2.php
<? echo "hello"; ?>
#/var/www/html/somescript.php
echo " world";
Expected result:
----------------
Output of "hello World";
and PHP should close all of its files it opened.
Actual result:
--------------
Output is proper.
PHP opens:
1) /tmp/test.php
2) /tmp/test2.php
3) /var/www/html/somescript.php
however, php only closes:
1) /tmp/test.php
2) /tmp/test2.php
it does NOT close 3) /var/www/html/somescript.php
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48104&edit=1
Thread (6 messages)