Edit report at https://bugs.php.net/bug.php?id=60218&edit=1
ID: 60218
User updated by: yohgaki at ohgaki dot net
Reported by: yohgaki at ohgaki dot net
Summary: dir() is missing
Status: Open
Type: Bug
Package: Unknown/Other Function
Operating System: Linux x86_64
PHP Version: 5.4SVN-2011-11-04 (SVN)
Block user comment: N
Private report: N
New Comment:
> 1. The documentation examples don't use 'new'. This works:
> php -r '$o = dir(".");'
It should always raise error for it, I suppose.
Strange thing is 'It works' sometimes.
If leak and other problem(works for sometimes) are specific to dir(), I think
dropping dir() is an option.
Previous Comments:
------------------------------------------------------------------------
[2011-11-04 18:08:58] [email protected]
1. The documentation examples don't use 'new'. This works:
php -r '$o = dir(".");'
2. SPL might have better alternatives, e.g.:
http://www.php.net/manual/en/class.recursivedirectoryiterator.php
3. I'll leave the bug open to track the memleak
------------------------------------------------------------------------
[2011-11-04 14:10:53] yohgaki at ohgaki dot net
dir is ancient class in PHP, so it may be the first one. It may be related.
Just
my guess.
------------------------------------------------------------------------
[2011-11-04 14:06:43] yohgaki at ohgaki dot net
s/I support dir()/I suppose dir()/
------------------------------------------------------------------------
[2011-11-04 14:02:52] yohgaki at ohgaki dot net
Description:
------------
I support dir() support is not dropped.
http://jp.php.net/manual/en/class.dir.php
At first, I noticed this issue on Scientific Linux 6's PHP and not with my
Linux
box. I though they have patched something for it, but I found it can happen
with
my Linux box, too.
This happens in PHP 5.3.3, PHP 5.3.8 and php-src-5.4 at least.
This may not be 100% reproducible, but I think chances are high in SL6. PHP may
be destroying class entry.
I'm not sure following valgrind result may help or not, but "echo 1" don't
report any leak.
$ USE_ZEND_ALLOC=0 valgrind --leak-check=full ./php -r '$o = new Dir(".");'
==24918== Memcheck, a memory error detector
==24918== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==24918== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==24918== Command: ./php -r $o\ =\ new\ Dir(".");
==24918==
PHP Fatal error: Class 'Dir' not found in Command line code on line 1
Fatal error: Class 'Dir' not found in Command line code on line 1
==24918==
==24918== HEAP SUMMARY:
==24918== in use at exit: 724 bytes in 6 blocks
==24918== total heap usage: 15,100 allocs, 15,094 frees, 3,101,573 bytes
allocated
==24918==
==24918== 724 (240 direct, 484 indirect) bytes in 1 blocks are definitely lost
in loss record 6 of 6
==24918== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==24918== by 0x7A6845: _emalloc (zend_alloc.c:2423)
==24918== by 0x782E75: compile_string (zend_language_scanner.l:717)
==24918== by 0x7CDC99: zend_eval_stringl (zend_execute_API.c:1181)
==24918== by 0x7CE00D: zend_eval_stringl_ex (zend_execute_API.c:1240)
==24918== by 0x7CE097: zend_eval_string_ex (zend_execute_API.c:1251)
==24918== by 0x93C6E1: do_cli (php_cli.c:1023)
==24918== by 0x93D625: main (php_cli.c:1356)
==24918==
==24918== LEAK SUMMARY:
==24918== definitely lost: 240 bytes in 1 blocks
==24918== indirectly lost: 484 bytes in 5 blocks
==24918== possibly lost: 0 bytes in 0 blocks
==24918== still reachable: 0 bytes in 0 blocks
==24918== suppressed: 0 bytes in 0 blocks
==24918==
==24918== For counts of detected and suppressed errors, rerun with: -v
==24918== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 6 from 6)
**********************************************************************
$ USE_ZEND_ALLOC=0 valgrind --leak-check=full ./php -r "echo 1;"
==28266== Memcheck, a memory error detector
==28266== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==28266== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==28266== Command: ./php -r echo\ 1;
==28266==
1==28266==
==28266== HEAP SUMMARY:
==28266== in use at exit: 0 bytes in 0 blocks
==28266== total heap usage: 15,078 allocs, 15,078 frees, 3,099,330 bytes
allocated
==28266==
==28266== All heap blocks were freed -- no leaks are possible
==28266==
==28266== For counts of detected and suppressed errors, rerun with: -v
==28266== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
Test script:
---------------
php -r '$o = new Dir(".");'
Expected result:
----------------
PHP should not complain
Actual result:
--------------
Fatal error: Class 'Dir' not found in Command line code on line 1
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60218&edit=1