#27992 [NEW]: Resource Leak
| From: | sean@php.net | Date: | Wed, 14 Apr 2004 15:41:00 +0000 |
| Subject: | #27992 [NEW]: Resource Leak | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-58128@lists.php.net to get a copy of this message | ||
From: sean@php.net
Operating system: Linux (any)
PHP version: 4.3.6RC3
PHP Bug Type: Class/Object related
Bug description: Resource Leak
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 bug report at http://bugs.php.net/?id=27992&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27992&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27992&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27992&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27992&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27992&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27992&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27992&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27992&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27992&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27992&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27992&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27992&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27992&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27992&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27992&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27992&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27992&r=float