From: Dmitry Stogov Date: Wed, 31 May 2006 12:59:31 +0000 (+0000) Subject: Support for nested exceptions and fatal errors in destructors X-Git-Tag: php-5.2.0RC1~405 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51e52e20ef9f1947658827fabb4bcb36aee40afd;p=php Support for nested exceptions and fatal errors in destructors --- diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c index 4918150aaf..e2d86e8fe8 100644 --- a/Zend/zend_objects.c +++ b/Zend/zend_objects.c @@ -103,9 +103,10 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl zval *file = zend_read_property(default_exception_ce, old_exception, "file", sizeof("file")-1, 1 TSRMLS_CC); zval *line = zend_read_property(default_exception_ce, old_exception, "line", sizeof("line")-1, 1 TSRMLS_CC); + zval_ptr_dtor(&EG(exception)); + EG(exception) = old_exception; zend_error(E_ERROR, "Ignoring exception from %s::__destruct() while an exception is already active (Uncaught %s in %s on line %ld)", object->ce->name, Z_OBJCE_P(old_exception)->name, Z_STRVAL_P(file), Z_LVAL_P(line)); - zval_ptr_dtor(&EG(exception)); } EG(exception) = old_exception; } diff --git a/Zend/zend_objects_API.c b/Zend/zend_objects_API.c index 83e7b5ff03..7ea9d14c68 100644 --- a/Zend/zend_objects_API.c +++ b/Zend/zend_objects_API.c @@ -165,6 +165,7 @@ ZEND_API void zend_objects_store_del_ref(zval *zobject TSRMLS_DC) ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSRMLS_DC) { struct _store_object *obj; + int failure = 0; if (!EG(objects_store).object_buckets) { return; @@ -182,12 +183,20 @@ ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSR EG(objects_store).object_buckets[handle].destructor_called = 1; if (obj->dtor) { - obj->dtor(obj->object, handle TSRMLS_CC); + zend_try { + obj->dtor(obj->object, handle TSRMLS_CC); + } zend_catch { + failure = 1; + } zend_end_try(); } } if (obj->refcount == 1) { if (obj->free_storage) { - obj->free_storage(obj->object TSRMLS_CC); + zend_try { + obj->free_storage(obj->object TSRMLS_CC); + } zend_catch { + failure = 1; + } zend_end_try(); } ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(); } @@ -203,6 +212,9 @@ ZEND_API void zend_objects_store_del_ref_by_handle(zend_object_handle handle TSR fprintf(stderr, "Decreased refcount of object id #%d\n", handle); } #endif + if (failure) { + zend_bailout(); + } } ZEND_API zend_object_value zend_objects_store_clone_obj(zval *zobject TSRMLS_DC)