__autoload() stream leak?
| From: | Jay Smith | Date: | Fri, 19 Mar 2004 17:16:45 +0000 |
| Subject: | __autoload() stream leak? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-8609@lists.php.net to get a copy of this message | ||
Hello, interals...
Kind of stumbled onto this by accident. Some kind of FD leak in streams. In
the current HEAD (and 5.0.0 RC1, I suppose, although I didn't specifically
test that, just my CVS checkout)...
class.one.php:
<?php class one {} ?>
class.two.php:
<?php class two extends one {} ?>
foo.php:
<?php
function __autoload($c)
{
require('bug_class.' . $c . '.php');
}
require('class.two.php');
$a = new two;
?>
jay@monty $ php5 foo.php
Warning: __autoload(bug_class.one.php): failed to open stream: No such file
or directory in /home/jay/bug/class.two.php on line 1
Fatal error: __autoload(): Failed opening required
'bug_class.one.php' (include_path='/usr/local/lib/php:.')
in /home/jay/bug/class.two.php on line 3
/home/jay/setup/php/php5/main/streams/streams.c(371) : Stream of type
'STDIO' 0x4014dfac (path:class.two.php) was not closed
Getting rid of the line that reads "require('class.two.php');" gets rid of
the leak. The "bug_class." in autoload() is also not a typo; fixing that
also gets rid of the leak (along with the warnings and such, too,
obviously.)
No idea what the problem is here, as my knowledge of the streams code is
pitiful.
J