ID: 15665
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Feedback
+Status: Open
Bug Type: Reproducible crash
Operating System: FreeBSD 4.4-STABLE
PHP Version: 4.1.1
New Comment:
The option is --enable-debug, right? --with-debug appeared to do
nothing. When compiled with --enable-debug, the script did not crash.
But it certainly crashes with a normal build without debugging.
Previous Comments:
------------------------------------------------------------------------
[2002-02-21 19:30:43] [EMAIL PROTECTED]
I'll compile PHP from source with debugging and test tomorrow. Can't
do it today since I just changed the code to exec find, and it already
processed today's files (is a webserver log processing helper script).
You're right, I know about the 0/false issue, but I was lazy since all
the filenames will always be fully qualified hostnames :)
I don't remember exactly how many times readdir() was being called
before it crashed, but probably somewhere between 100-200. When it
first crashed, I noticed I had been calling that function a lot without
using closedir(), but after I added it and only called it once on a
single directory, it still crashed.
------------------------------------------------------------------------
[2002-02-21 18:50:04] [EMAIL PROTECTED]
Can you enable --with-debug please and post a backtrace?
Btw, how often have you to call readdir() until it crashes?
Btw, your code won't work for directories containing files or dirs
naming like '0'; see the manual page and use 'while (false !== ($s =
readdir() ...'
Also, can you try the source relese itself please and not a/the port?
------------------------------------------------------------------------
[2002-02-21 17:24:16] [EMAIL PROTECTED]
readdir() is consistently crashing PHP in one of my scripts.
Unfortunately, I can't reproduce the problem with a small test script,
for some reason. However, the function that is causing PHP to scrash
is shown below. It is crashing after a number of readdir() calls:
function list_dir($name)
{
$d = opendir($name);
while ($s = readdir($d))
if (($s != ".") && ($s != ".."))
$a[] = $s;
closedir($d);
return isset($a) ? $a : false;
}
This is the CGI version, running from the command line. A backtrace is
shown below:
(gdb) bt
#0 0x286ed20d in readdir_r () from /usr/lib/libc.so.4
#1 0x80dbd9b in php_if_readdir ()
#2 0x8146e04 in execute ()
#3 0x8146ffd in execute ()
#4 0x8146ffd in execute ()
#5 0x8146ffd in execute ()
#6 0x8129418 in zend_execute_scripts ()
#7 0x806e6be in php_execute_script ()
#8 0x806c8d0 in main ()
#9 0x806bcd3 in _start ()
I can provide more information if necessary. PHP was compiled from
ports within the last week.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=15665&edit=1