ID:               34062
 User updated by:  feldgendler at mail dot ru
 Reported By:      feldgendler at mail dot ru
 Status:           Assigned
 Bug Type:         Reproducible crash
 Operating System: Debian GNU/Linux
 PHP Version:      6.0.0-dev
 Assigned To:      dmitry
 New Comment:

"Version: 6.0.0-dev"

Is this a misprint?


Previous Comments:
------------------------------------------------------------------------

[2005-08-10 10:19:22] [EMAIL PROTECTED]

Dmitry, take a look at it plz, I can reproduce it with the latest CVS.

------------------------------------------------------------------------

[2005-08-10 08:52:45] feldgendler at mail dot ru

Description:
------------
PHP crashes in a catch block. It happened in a real program, and I've
gradually reduced its complexity until I came to the simple testcase
I'm posting below. Both mod_php5 for Apache 2 and php5-cli crash on
this testcase.

Here is what I found during research:

In the beginning, I had multiple functions calling each other, like
this:

catch (Exception $e) {
    function f2() { f3(0, 0); }
}
function f3() { f4(0, 0, 0); }
function f4() { f5(0, 0); }

...up to a quite deep nesting. I found that I can keep PHP crashing if
I carry the zeros from one function call to another, as long as their
total number does not decrese. I could even carry the zeros between the
catch block and the try block. Also I could exchange one level of
nesting for two additional zeros. So I collapsed them all in the
argument list of max(). The max() function was chosen arbitararily, any
function that takes unlimited number of arguments will do. The zeros can
also be replaced with values of any type. The crash can also be
reproduced using set_exception_handler() instead of a catch block.

Reproduce code:
---------------
<?

function f1() { throw new Exception; }
function f2() { echo "here\n"; }

try {
      // Currently it's the minimum required number of zeros
      // If you remove one, it won't crash
        max(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, f1());
} catch (Exception $e) {
        echo "(((\n";
        f2(0, 0, 0); // Won't crash if less than 3 zeros here
        echo ")))\n";
}

?>

Expected result:
----------------
(((
here
)))

Actual result:
--------------
(((
here
Segmentation fault

Here is the stack dump (obtained from php-cli):

#0  0x081fb0b6 in _zval_ptr_dtor ()
#1  0x0822b47c in zend_do_fcall_common_helper ()
#2  0x0823bb73 in zend_do_fcall_handler ()
#3  0x08228c39 in execute ()
#4  0x08208414 in zend_execute_scripts ()
#5  0x081ce03d in php_execute_script ()
#6  0x0824c284 in main ()


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=34062&edit=1

Reply via email to