php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36581 Segment fault doing directory recursion stuff
Submitted: 2006-03-02 02:17 UTC Modified: 2006-03-10 01:00 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:0 of 1 (0.0%)
From: t dot stobbe at blackdogdev dot com Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: 5.1.2 OS: Debian (sarge): 2.4.27-2.i386
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
39 - 18 = ?
Subscribe to this entry?

 
 [2006-03-02 02:17 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-02 08:00 UTC] 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 08:45 UTC] tony2001@php.net
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.


 [2006-03-10 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 15:01:29 2024 UTC