File descriptor leaked due to HAVE_BROKEN_GETCWD
| Bug #47675 | File descriptor leaked due to HAVE_BROKEN_GETCWD | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2009-03-16 14:07 UTC | Modified: | 2013-04-05 02:30 UTC |
|
||||||||||
| From: | cs at ecn dot purdue dot edu | Assigned: | rasmus (profile) | |||||||||||
| Status: | Closed | Package: | Apache2 related | |||||||||||
| PHP Version: | 5.2.9 | OS: | Solaris 10 | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2009-03-16 14:07 UTC] cs at ecn dot purdue dot edu
Description: ------------ mod_php contains a potential file descriptor leak on Solaris 10 when script executes "exit()". Reproduce code: --------------- <?php exit(0); ?> The change in behavior is due to the addition of HAVE_BROKEN_GETCWD for Solaris 10. In php_execute_script, a file descriptor is opened to hold the current working directory, but is not closed in the case where php code may not return to this function after executing a script. mod_php isn't aware of the resource that was allocated and not freed. Expected result: ---------------- Normally web server runs for days without resource trouble. In the case where a PHP script does an "exit(0)", the web server will run out of file descriptors and will need restarting.
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2009-03-16 16:25 UTC] cs at ecn dot purdue dot edu
[2009-06-22 00:18 UTC] dsp@php.net
[2009-06-29 01:00 UTC] php-bugs at lists dot php dot net
[2010-01-09 06:59 UTC] bryan at stansell dot org
[2010-01-12 15:40 UTC] bryan at stansell dot org
I finally got a chance to test a theory. Looks like the volatile attribute fixed things for me. #if HAVE_BROKEN_GETCWD volatile int old_cwd_fd = -1; #else Once I added that, the setjmp/longjmp worked as expected. I got the idea from the manpage on Solaris: The values of register and automatic variables are unde- fined. Register or automatic variables whose value must be relied upon must be declared as volatile. Perhaps it's a gcc/gas/Solaris/x86 optimization somewhere that overlooked the case, but this is a workaround. Of course, undefining HAVE_BROKEN_GETCWD for Solaris also works, if you have a web tree that isn't restricted in some way.[2010-08-08 10:20 UTC] php at marino dot st
[2011-05-18 18:23 UTC] pyorke at joyent dot com
[2011-09-28 00:58 UTC] jsjohnst@php.net
[2013-04-04 20:56 UTC] davek at gamehouse dot com
[2013-04-05 02:30 UTC] rasmus@php.net
-Status: Re-Opened +Status: Closed -Assigned To: +Assigned To: rasmus
[2013-04-05 02:30 UTC] rasmus@php.net