dmitry Thu, 09 Dec 2010 16:38:37 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=306135
Log: Fixed bug #53511 (Exceptions are lost in case an exception is thrown in catch operator) Bug: http://bugs.php.net/53511 (Assigned) Exceptions are lost in case an exception is thrown in catch operator Changed paths: A php/php-src/trunk/Zend/tests/bug53511.phpt U php/php-src/trunk/Zend/zend_vm_def.h U php/php-src/trunk/Zend/zend_vm_execute.h U php/php-src/trunk/ext/spl/tests/iterator_041b.phpt Added: php/php-src/trunk/Zend/tests/bug53511.phpt =================================================================== --- php/php-src/trunk/Zend/tests/bug53511.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/bug53511.phpt 2010-12-09 16:38:37 UTC (rev 306135) @@ -0,0 +1,33 @@ +--TEST-- +Bug #53511 (Exceptions are lost in case an exception is thrown in catch operator) +--FILE-- +<?php +class Foo { + function __destruct() { + throw new Exception("ops 1"); + } +} + +function test() { + $e = new Foo(); + try { + throw new Exception("ops 2"); + } catch (Exception $e) { + echo $e->getMessage()."\n"; + } +} + +test(); +echo "bug\n"; +--EXPECTF-- +Fatal error: Uncaught exception 'Exception' with message 'ops 2' in %sbug53511.php:11 +Stack trace: +#0 %sbug53511.php(17): test() +#1 {main} + +Next exception 'Exception' with message 'ops 1' in %sbug53511.php:4 +Stack trace: +#0 %sbug53511.php(12): Foo->__destruct() +#1 %sbug53511.php(17): test() +#2 {main} + thrown in %sbug53511.php on line 4 Modified: php/php-src/trunk/Zend/zend_vm_def.h =================================================================== --- php/php-src/trunk/Zend/zend_vm_def.h 2010-12-09 16:33:45 UTC (rev 306134) +++ php/php-src/trunk/Zend/zend_vm_def.h 2010-12-09 16:38:37 UTC (rev 306135) @@ -2918,7 +2918,7 @@ &EG(exception), sizeof(zval *), (void**)&EX_CV(opline->op2.var)); } if (UNEXPECTED(EG(exception) != exception)) { - EG(exception) = NULL; + Z_ADDREF_P(EG(exception)); HANDLE_EXCEPTION(); } else { EG(exception) = NULL; Modified: php/php-src/trunk/Zend/zend_vm_execute.h =================================================================== --- php/php-src/trunk/Zend/zend_vm_execute.h 2010-12-09 16:33:45 UTC (rev 306134) +++ php/php-src/trunk/Zend/zend_vm_execute.h 2010-12-09 16:38:37 UTC (rev 306135) @@ -5843,7 +5843,7 @@ &EG(exception), sizeof(zval *), (void**)&EX_CV(opline->op2.var)); } if (UNEXPECTED(EG(exception) != exception)) { - EG(exception) = NULL; + Z_ADDREF_P(EG(exception)); HANDLE_EXCEPTION(); } else { EG(exception) = NULL; Modified: php/php-src/trunk/ext/spl/tests/iterator_041b.phpt =================================================================== --- php/php-src/trunk/ext/spl/tests/iterator_041b.phpt 2010-12-09 16:33:45 UTC (rev 306134) +++ php/php-src/trunk/ext/spl/tests/iterator_041b.phpt 2010-12-09 16:38:37 UTC (rev 306135) @@ -82,6 +82,10 @@ { self::$fail++; } + try { + $e = null; + } catch (Exception $e) { + } } } } @@ -101,10 +105,19 @@ State 4: current() State 5: key() State 6: next() +State 7: __destruct() +array(2) { + [0]=> + int(1) + [1]=> + int(2) +} ===iterator_count=== State 0: __construct() State 1: __construct() State 2: rewind() State 3: valid() State 6: next() +State 7: __destruct() +int(2) ===DONE===
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php