Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Zend/tests/bug62763.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ class test1 {
register_shutdown_function(array($this, 'shutdown'));
}
public function shutdown() {
exit(__METHOD__);
exit(static::class . '::' . __FUNCTION__ . "\n");
}
}

class test2 extends test1 {
public function __destruct() {
exit (__METHOD__);
exit(static::class . '::' . __FUNCTION__ . "\n");
}
}
new test1;
new test2;
?>
--EXPECT--
test1::shutdowntest2::__destruct
test1::shutdown
test2::shutdown
test2::__destruct
20 changes: 20 additions & 0 deletions Zend/tests/gh18619.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Gh-18619: exit() from error handler should not trigger bailout
--FILE--
<?php

function foo($e) {
exit;
}

set_exception_handler('foo');

register_shutdown_function(function () {
var_dump(set_exception_handler(null));
});

throw new Error();

?>
--EXPECT--
string(3) "foo"
10 changes: 7 additions & 3 deletions Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,13 @@ ZEND_API ZEND_COLD void zend_throw_exception_internal(zend_object *exception) /*
return;
}
if (EG(exception)) {
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF
&& !zend_is_unwind_exit(EG(exception))
&& !zend_is_graceful_exit(EG(exception))) {
if (zend_is_unwind_exit(EG(exception))
|| zend_is_graceful_exit(EG(exception))) {
/* Stack is fully unwound, clear the unwind exit. */
zend_exception_error(EG(exception), E_ERROR);
return;
}
if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
zend_user_exception_handler();
if (EG(exception)) {
zend_exception_error(EG(exception), E_ERROR);
Expand Down