1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 03:03:26 +02:00

Support for nested exceptions and fatal errors in destructors

This commit is contained in:
Dmitry Stogov
2006-05-31 12:59:45 +00:00
parent 4b2d974691
commit 75fac72dc5
2 changed files with 16 additions and 3 deletions
+2 -1
View File
@@ -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 %v::__destruct() while an exception is already active (Uncaught %v in %R on line %ld)",
object->ce->name, Z_OBJCE_P(old_exception)->name, Z_TYPE_P(file), Z_UNIVAL_P(file), Z_LVAL_P(line));
zval_ptr_dtor(&EG(exception));
}
EG(exception) = old_exception;
}
+14 -2
View File
@@ -173,6 +173,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;
@@ -190,12 +191,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();
}
@@ -211,6 +220,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)