From: [EMAIL PROTECTED] Operating system: FreeBSD PHP version: 4.2.2 PHP Bug Type: Reproducible crash Bug description: Segmentation fault (11) in recursive function call
I get this all the time when I include a recursive function call. I've tried rewriting the function several ways and get intermitten Segmentation faults, saw a SuSe Linux report about scripts terminating with similar output in the web server error_log. I"ve tried just opening the fh and going down recursive directories with this, got the seg faults often.This version buffers the file names in an array, closes the directory handle then processes the array, to count certain types of files in the directory tree. Still segfaults often enough to make it unreliable. I turned on the autoflush in php.ini and it dies in this routine. FreeBSD 4.5-RELEASE Apache/1.3.26 (Unix) PHP/4.2.2 mod_ssl/2.8.9 OpenSSL/0.9.6g RegisterGlobals = On :) I use a perl script for my apache coplilation, here's my php_config line. --with-mysql=/usr/local --with-gd=/usr/local --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/ local/lib --with-zlib-dir=/usr/lib $xpm --with-freetype-dir=/usr/local/lib --with-mcrypt=/usr/local --with-gettext --wit h-xml --with-zlib=/usr --with-bz2=/usr/local --with-zip=/usr/local --with-mm=/usr/local --with-apache=../$apache --enable-ftp --disable-debug --enable-track-vars Here's the current version of the function function CountFiles($dir,$d) { global $home; global $prod_count; $farray = array(); $d++; if (is_dir("$home$dir")) { print "<!-- ISDIR dir=$dir level=$d -->\n"; if ($dfh = @opendir("$home$dir")) { while (($fil = readdir($dfh)) !== false) { if (!preg_match("/^\.+$/", $fil)) { array_push($farray,"$fil"); } } closedir($dfh); if (count($farray) > 0) { while (list ($key, $file) = each ($farray)) { if (is_dir("$home$dir/$file")) { CountFiles("$dir/$file",$d); flush(); } else if (preg_match("/^thumb_\w+\.|\.wav$|\.aif$/", $file)) { $prod_count++; print "<!-- POST dir=$dir/$file prod_count=$prod_count -->\n"; flush(); } } } } } flush(); } It's not entirely reproducible, but once I got a directory where it causes the segfault I can comment out this routine and it's okay, comment it back and reload and it segfaults. So in that sense it's reproducible. Restarting the web server has no effect. Though if I reload enough times sometimes the script completes, there is definitely some sort of bug, maybe the filehandle or array declaration isn't local or leaks out, not sure. Hope it's not something stupid I overlooked. :) -- Edit bug report at http://bugs.php.net/?id=20186&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20186&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20186&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20186&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20186&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20186&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20186&r=support Expected behavior: http://bugs.php.net/fix.php?id=20186&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20186&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20186&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20186&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20186&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20186&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20186&r=isapi