cvs: ZendEngine2(PHP_5_3) / zend.c /tests bug47714.phpt php-src NEWS

[email protected] ("Dmitry Stogov") Thu, 26 Mar 2009 10:56:45 -0000
Newsgroups php.zend-engine.cvs
Message-ID <cvsdmitry1238065005@cvsserver>
dmitry		Thu Mar 26 10:56:45 2009 UTC

  Added files:                 (Branch: PHP_5_3)
    /ZendEngine2/tests	bug47714.phpt 

  Modified files:              
    /php-src	NEWS 
    /ZendEngine2	zend.c 
  Log:
  Fixed bug #47714 (autoloading classes inside exception_handler leads to crashes)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.535&r2=1.2027.2.547.2.965.2.536&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.535 php-src/NEWS:1.2027.2.547.2.965.2.536
--- php-src/NEWS:1.2027.2.547.2.965.2.535	Thu Mar 26 10:17:27 2009
+++ php-src/NEWS	Thu Mar 26 10:56:45 2009
@@ -5,6 +5,8 @@
   (Matteo)
 - Fixed bug #47771 (Exception during object construction from arg call calls
   object's destructor). (Dmitry)
+- Fixed bug #47714 (autoloading classes inside exception_handler leads to
+  crashes). (Dmitry)
 - Fixed bug #47699 (autoload and late static binding). (Dmitry)
 - Fixed bug #47038 (Memory leak in include). (Dmitry)
 - Fixed bug #44409 (PDO::FETCH_SERIALIZE calls __construct()). (Matteo)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.c?r1=1.308.2.12.2.35.2.30&r2=1.308.2.12.2.35.2.31&diff_format=u
Index: ZendEngine2/zend.c
diff -u ZendEngine2/zend.c:1.308.2.12.2.35.2.30 ZendEngine2/zend.c:1.308.2.12.2.35.2.31
--- ZendEngine2/zend.c:1.308.2.12.2.35.2.30	Wed Mar 18 10:18:09 2009
+++ ZendEngine2/zend.c	Thu Mar 26 10:56:45 2009
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend.c,v 1.308.2.12.2.35.2.30 2009/03/18 10:18:09 dmitry Exp $ */
+/* $Id: zend.c,v 1.308.2.12.2.35.2.31 2009/03/26 10:56:45 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_extensions.h"
@@ -1192,20 +1192,20 @@
 					zval *orig_user_exception_handler;
 					zval **params[1], *retval2, *old_exception;
 					old_exception = EG(exception);
-					zend_exception_save(TSRMLS_C);
+					EG(exception) = NULL;
 					params[0] = &old_exception;
 					orig_user_exception_handler = EG(user_exception_handler);
 					if (call_user_function_ex(CG(function_table), NULL, orig_user_exception_handler, &retval2, 1, params, 1, NULL TSRMLS_CC) == SUCCESS) {
 						if (retval2 != NULL) {
 							zval_ptr_dtor(&retval2);
 						}
-						zend_exception_restore(TSRMLS_C);
 						if (EG(exception)) {
 							zval_ptr_dtor(&EG(exception));
 							EG(exception) = NULL;
 						}
+						zval_ptr_dtor(&old_exception);
 					} else {
-						zend_exception_restore(TSRMLS_C);
+						EG(exception) = old_exception;
 						zend_exception_error(EG(exception), E_ERROR TSRMLS_CC);
 					}
 				} else {

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug47714.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug47714.phpt
+++ ZendEngine2/tests/bug47714.phpt
--TEST--
--FILE--
<?php
function au($class) {
        eval('class handler {
                  function handle($e) {
                      echo $e->getMessage()."\n";
                  }
              }');
}

function __autoload($class) {
        au($class);
}

//spl_autoload_register('au');

set_exception_handler(function($exception) {
        $h = new handler();
        $h->handle($exception);
});

throw new Exception('exception');
?>
--EXPECT--
exception