#32254 [NEW]: Nested try-catch blocks may cause segfault

From: Date: Wed, 09 Mar 2005 13:53:00 +0000
Subject: #32254 [NEW]: Nested try-catch blocks may cause segfault
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-75169@lists.php.net to get a copy of this message
From:             shulmanb at il dot ibm dot com
Operating system: Linux
PHP version:      5CVS-2005-03-09 (dev)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  Nested try-catch blocks may cause segfault

Description:
------------
When compiled with --enable-maintainer-zts, having nested try-catch blocks
may cause segfaults in some cases.

In the following code fragment, commenting out the outer try-catch block
solves the segfault.

This DOES NOT HAPPEN when compiled with debug symbols.

This may be related to bug #32252 (for instance, if the index to $list is
positive, crash does not occur).

Reproduce code:
---------------
class a implements ArrayAccess {
    function offsetExists ($offset) { return false; }
    function offsetGet ($offset) { return null; }
    function offsetSet ($offset, $value) { throw new Exception ("Oops");
}
    function offsetUnset ($offset) { }
}
function test () {
    try {
        $list = new a();
        $caught = 0;
        try {
            $list[-1] = 123;
        } catch (Exception $e) {
            $caught = 1;
        }
        if (!$caught)
            return false;
        return true;
    }
    catch (Exception $e) {
        return false;
    }
}
print test();

Expected result:
----------------
The output should be "1"

Actual result:
--------------
Segmentation fault.

PHP was compiled without debug symbols. The stack trace provided by gdb
was:

#0  0x08184ecd in zend_hash_destroy (ht=0x8c579c08)
    at /root/php-5.0.3/Zend/zend_hash.c:524

-- 
Edit bug report at http://bugs.php.net/?id=32254&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32254&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32254&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32254&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32254&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32254&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32254&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32254&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32254&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32254&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32254&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=32254&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=32254&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32254&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32254&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32254&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32254&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32254&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32254&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32254&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32254&r=mysqlcfg


Thread (4 messages)

« previous php.bugs (#75169) next »