#36581 [Opn->Fbk]: Segment fault doing directory recursion stuff

From: Date: Thu, 02 Mar 2006 07:45:15 +0000
Subject: #36581 [Opn->Fbk]: Segment fault doing directory recursion stuff
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-93826@lists.php.net to get a copy of this message
ID: 36581 Updated by: tony2001@php.net Reported By: t dot stobbe at blackdogdev dot com -Status: Open +Status: Feedback Bug Type: Reproducible crash Operating System: Debian (sarge): 2.4.27-2.i386 PHP Version: 5.1.2 New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try to avoid embedding huge scripts into the report. Previous Comments: ------------------------------------------------------------------------ [2006-03-02 08:00:26] judas dot iscariote at gmail dot com Well.if you try to use a "modern" thing like RecursiveDirectoryIterator it also segfaults ?? http://www.php.net/~helly/php/ext/spl/classRecursiveDirectoryIterator.html most likely you are triggering an infinite loop. ------------------------------------------------------------------------ [2006-03-02 02:17:07] t dot stobbe at blackdogdev dot com Description: ------------ I'm trying to do stuff recursively on a filesystem. To simplify, call do_path($path) { $dh = opendir($path) ... if (is_dir($file)) { do_path($path . $file); } else { process_file($path . $file); } Of course I'm checking for "." and ".." to prevent infinate loops. proccess_file() loads the file contents and does regex stuff on it. After 4 subdirectories in, and processing about 1000 files, it crashes with a segment fault. I've even tryed manually unsetting all vars after being used, but to no avail. It crashes at the same place in the file system each time. Reproduce code: --------------- Email me. I can't post the code and it's way to large. Expected result: ---------------- All files and directories (within reason) would be processed properly, similar to the way `du' works. Actual result: -------------- Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 9057)] 0x08231e81 in virtual_file_ex (state=0xbfe024a8, path=0x85e1284 "/home/legacy/public_html/gd_temp/Customer Testimonials.psd", verify_path=0, use_realpath=1) at /usr/local/src/php-5.1.2/TSRM/tsrm_virtual_cwd.c:374 374 int path_length = strlen(path); (gdb) bt #0 0x08231e81 in virtual_file_ex (state=0xbfe024a8, path=0x85e1284 "/home/legacy/public_html/gd_temp/Customer Testimonials.psd", verify_path=0, use_realpath=1) at /usr/local/src/php-5.1.2/TSRM/tsrm_virtual_cwd.c:374 #1 0x082396dd in expand_filepath (filepath=0x85e1284 "/home/legacy/public_html/gd_temp/Customer Testimonials.psd", real_path=0x0) at /usr/local/src/php-5.1.2/main/fopen_wrappers.c:529 #2 0x082495f3 in _php_stream_fopen (filename=0x85e1284 "/home/legacy/public_html/gd_temp/Customer Testimonials.psd", mode=0x850efec "rb", opened_path=0x0, options=4) at /usr/local/src/php-5.1.2/main/streams/plain_wrapper.c:855 #3 0x082464a7 in _php_stream_open_wrapper_ex (path=0x85e1284 "/home/legacy/public_html/gd_temp/Customer Testimonials.psd", mode=0x850efec "rb", options=12, opened_path=0x0, context=0x80808000) at /usr/local/src/php-5.1.2/main/streams/streams.c:1771 #4 0x081dd7c3 in php_if_fopen (ht=140382852, return_value=0x88d5da4, return_value_ptr=0x0, this_ptr=0x0, return_value_used=1) at /usr/local/src/php-5.1.2/ext/standard/file.c:840 #5 0x08286d46 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfe03810) at zend_vm_execute.h:192 #6 0x08286658 in execute (op_array=0x84cdf18) at zend_vm_execute.h:92 #7 0x08286b21 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfe041d0) at zend_vm_execute.h:226 #8 0x08286658 in execute (op_array=0x84dcb10) at zend_vm_execute.h:92 #9 0x08286b21 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfe04510) at zend_vm_execute.h:226 #10 0x08286658 in execute (op_array=0x84dd160) at zend_vm_execute.h:92 #11 0x08286b21 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfe04ed0) at zend_vm_execute.h:226 ... zend_do_fcall_common_helper_SPEC()/execute() repeats like this until ... #2497 0x0826e410 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/local/src/php-5.1.2/Zend/zend.c:1101 #2498 0x0823594d in php_execute_script (primary_file=0xbffff9f0) at /usr/local/src/php-5.1.2/main/main.c:1720 #2499 0x082d28bf in main (argc=12, argv=0xbffffa94) at /usr/local/src/php-5.1.2/sapi/cli/php_cli.c:1077 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36581&edit=1

« previous php.bugs (#93826) next »