|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-02-21 17:24 UTC] david at acz dot org
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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 16:00:01 2025 UTC |
I have very similar thing happening. Script is reading directory with a lot of image files, printing them in colors. The script crash as both mod_php4 in apache and command-line. It crash every time at same position, however it crash in different positions when called thru apache and when run from command line. Relevant part of script: $handle = opendir("/home/pav/images/fit"); while ($fajl = readdir($handle)) { if ($fajl == "." || $fajl == "..") continue; echo '<a href="wow.php3?showme='.$fajl.'" target="_blank" style="color: '; if ($rates[$fajl]) echo calclinkcolor($ratingy[$fajl]); else echo calclinkcolor(-1); echo '">'.$fajl."</a>\n"; } closedir($handle); backtrace #0 0x2836aaed in readdir_r () from /usr/lib/libc.so.4 (gdb) bt #0 0x2836aaed in readdir_r () from /usr/lib/libc.so.4 #1 0x8091935 in php_if_readdir () #2 0x80ed79c in execute () #3 0x80d9171 in zend_execute_scripts () #4 0x8062406 in php_execute_script () #5 0x8060288 in main () #6 0x805f629 in _start () PHP 4.2.1, Apache 1.3.24, FreeBSD 4.5-STABLEHere it is: ~/www/local/wow $ gdb php php.core GNU gdb 4.18 Core was generated by `php'. Program terminated with signal 11, Segmentation fault. Reading symbols from /usr/lib/libpam.so.1...done. Reading symbols from /usr/lib/libcrypt.so.2...done. Reading symbols from /usr/lib/libm.so.2...done. Reading symbols from /usr/lib/libc.so.4...done. Reading symbols from /usr/libexec/ld-elf.so.1...done. #0 0x2822daed in readdir_r () from /usr/lib/libc.so.4 (gdb) bt #0 0x2822daed in readdir_r () from /usr/lib/libc.so.4 #1 0x809909d in php_if_readdir (ht=1, return_value=0x82fa724, this_ptr=0x0, return_value_used=1) at dir.c:341 #2 0x8139522 in execute (op_array=0x81c3224) at ./zend_execute.c:1598 #3 0x8112e91 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at zend.c:810 #4 0x806064d in php_execute_script (primary_file=0xbfbff984) at main.c:1381 #5 0x805dd10 in main (argc=3, argv=0xbfbffa00) at cgi_main.c:778 #6 0x805ce25 in _start () Can you make something from it?