Skip to content

Commit

Permalink
Fix GH-17408: Assertion failure Zend/zend_exceptions.c
Browse files Browse the repository at this point in the history
`zend_test_create_throwing_resource` sets the exception in the `test`
call frame and unwinds to `main`. It then throws for the `resource`
variable and verifies that the exception opline is set. However, it
wasn't set in `main`, it was set at the `test` call frame and rethrown later.
The assertion is too conservative, but the end result is right, so drop
the assertion.

Closes GH-17533.

Co-authored-by: Ilija Tovilo <[email protected]>
  • Loading branch information
nielsdos and iluuu1994 committed Jan 21, 2025
1 parent 191e16b commit 5344bcc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ PHP NEWS
. Fixed NULL arithmetic during system program execution on Windows. (cmb,
nielsdos)
. Fixed potential OOB when checking for trailing spaces on Windows. (cmb)
. Fixed bug GH-17408 (Assertion failure Zend/zend_exceptions.c).
(nielsdos, ilutov)

- DOM:
. Fixed bug GH-17500 (Segfault with requesting nodeName on nameless doctype).
Expand Down
1 change: 0 additions & 1 deletion Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ ZEND_API ZEND_COLD void zend_throw_exception_internal(zend_object *exception) /*
zend_exception_set_previous(exception, EG(exception));
EG(exception) = exception;
if (previous) {
ZEND_ASSERT(is_handle_exception_set() && "HANDLE_EXCEPTION not set?");
return;
}
}
Expand Down
22 changes: 22 additions & 0 deletions ext/zend_test/tests/gh17408.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
GH-17408 (Assertion failure Zend/zend_exceptions.c)
--EXTENSIONS--
zend_test
--FILE--
<?php
function test() {
$resource = zend_test_create_throwing_resource();
zend_test_create_throwing_resource();
}
test();
?>
--EXPECTF--
Fatal error: Uncaught Exception: Throwing resource destructor called in %s:%d
Stack trace:
#0 %s(%d): test()
#1 {main}

Next Exception: Throwing resource destructor called in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d

0 comments on commit 5344bcc

Please sign in to comment.