File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Gh-18619: exit() from error handler should not trigger bailout
3
+ --FILE--
4
+ <?php
5
+
6
+ function foo ($ e ) {
7
+ exit ;
8
+ }
9
+
10
+ set_exception_handler ('foo ' );
11
+
12
+ register_shutdown_function (function () {
13
+ var_dump (set_exception_handler (null ));
14
+ });
15
+
16
+ throw new Error ();
17
+
18
+ ?>
19
+ --EXPECT--
20
+ string(3) "foo"
Original file line number Diff line number Diff line change @@ -210,9 +210,13 @@ ZEND_API ZEND_COLD void zend_throw_exception_internal(zend_object *exception) /*
210
210
return ;
211
211
}
212
212
if (EG (exception )) {
213
- if (Z_TYPE (EG (user_exception_handler )) != IS_UNDEF
214
- && !zend_is_unwind_exit (EG (exception ))
215
- && !zend_is_graceful_exit (EG (exception ))) {
213
+ if (zend_is_unwind_exit (EG (exception ))
214
+ || zend_is_graceful_exit (EG (exception ))) {
215
+ /* Stack is fully unwound, clear the unwind exit. */
216
+ zend_exception_error (EG (exception ), E_ERROR );
217
+ return ;
218
+ }
219
+ if (Z_TYPE (EG (user_exception_handler )) != IS_UNDEF ) {
216
220
zend_user_exception_handler ();
217
221
if (EG (exception )) {
218
222
zend_exception_error (EG (exception ), E_ERROR );
You can’t perform that action at this time.
0 commit comments