#27992 [Fbk]: Resource Leak
| From: | gschlossnagle@php.net | Date: | Thu, 15 Apr 2004 14:05:43 +0000 |
| Subject: | #27992 [Fbk]: Resource Leak | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-58191@lists.php.net to get a copy of this message | ||
ID: 27992
Updated by: gschlossnagle@php.net
Reported By: sean@php.net
Status: Feedback
Bug Type: Class/Object related
Operating System: Linux (any)
PHP Version: 4.3.6RC3
New Comment:
The segfault is a known (and I believe wont-be-fixed-in
-4)
bug in the reference counting implementation.
Previous Comments:
------------------------------------------------------------------------
[2004-04-15 10:02:33] sean@php.net
First, $sock should get re-allocated in each iteration, thereby forcing
the former $sock (and it's ->fp) out of scope.
Second, the connect() method for $sock checks to see if it already has
an allocated $fp; and if so, does an fclose.
While this example isn't practical, this problem directly affects
PEAR's HTTP_Request code (but this still isn't a PEAR issue).
S
------------------------------------------------------------------------
[2004-04-14 22:34:20] sniper@php.net
Why woudln't it run out of file handles when you never CLOSE the
socket..?
------------------------------------------------------------------------
[2004-04-14 11:41:00] sean@php.net
Description:
------------
See the attached code; it has been isolated from PEAR (core) and
PEAR::Net_Socket.
Basically, after a certain number of iterations (Linux, PHP4.3.4 and
4.3.6RC3, likely others), PHP runs out of file resources.
Warning: fsockopen(): unable to connect to 192.168.100.51:80 in
/home/sean/www/dev3/crashing_resources.php on line 51
ERROR: 24 - Too many open files
This SEEMS to be a leak (file handles are never closed?) in
method_exists, get_classname or get_parent_classname, because if I
remove the ShrunkenPEAR constructor (OR, the _ShrunkenPEAR method), the
code does not fail.
Additionally, if I instanciate ShrunkenSocket as $sock = new
ShrunkenSocket() (value instead of reference), the error is also
absent. The reason I'm using a reference: PEAR::HTTP_Request
instanciates Net_Socket as such.
Also, as mentioned in a comment in the code, if I change the die to an
echo, the script segfaults after ~65535 iterations (which seems like an
overflow problem).
** Note: this was originally posted to internals@ (PHP-DEV), but did
not get a response.**
This COULD be a critical overflow problem (when segfaulting), but I
don't know enough about the matter to declare it so.
Reproduce code:
---------------
http://sean.caedmon.net/php/crashing_resources.phps
Expected result:
----------------
(see description)
Actual result:
--------------
(see description)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27992&edit=1