Skip to content

Commit 553d79c

Browse files
committed
Fix phpGH-16799: Assertion failure at Zend/zend_vm_execute.h:7469
zend_is_callable_ex() can unfortunately emit a deprecation, and then a user error handler can throw an exception. This causes an assert failure at ZEND_VM_NEXT_OPCODE(). We fix this by checking if there's an exception after zend_is_callable_ex(). Closes phpGH-16803.
1 parent f725f50 commit 553d79c

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ PHP NEWS
99
. Fail early in *nix configuration build script. (hakre)
1010
. Fixed bug GH-16727 (Opcache bad signal 139 crash in ZTS bookworm
1111
(frankenphp)). (nielsdos)
12+
. Fixed bug GH-16799 (Assertion failure at Zend/zend_vm_execute.h:7469).
13+
(nielsdos)
1214

1315
- FPM:
1416
. Fixed GH-16432 (PHP-FPM 8.2 SIGSEGV in fpm_get_status). (Jakub Zelenka)

Zend/tests/gh16799.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
GH-16799 (Assertion failure at Zend/zend_vm_execute.h)
3+
--FILE--
4+
<?php
5+
set_error_handler(function($_, $m) { throw new Exception($m); });
6+
class Test {
7+
static function test() {
8+
call_user_func("static::ok");
9+
}
10+
static function ok() {
11+
}
12+
}
13+
Test::test();
14+
?>
15+
--EXPECTF--
16+
Fatal error: Uncaught Exception: Use of "static" in callables is deprecated in %s:%d
17+
Stack trace:
18+
#0 %s(%d): {closure}(%d, 'Use of "static"...', %s, %d)
19+
#1 %s(%d): Test::test()
20+
#2 {main}
21+
thrown in %s on line %d

Zend/zend_vm_def.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3807,6 +3807,16 @@ ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMPVAR|CV, NUM)
38073807
function_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
38083808
if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) {
38093809
ZEND_ASSERT(!error);
3810+
3811+
/* Deprecation can be emitted from zend_is_callable_ex(), which can
3812+
* invoke a user error handler and throw an exception.
3813+
* For the CONST and CV case we reuse the same exception block below
3814+
* to make sure we don't increase VM size too much. */
3815+
if (!(OP2_TYPE & (IS_TMP_VAR|IS_VAR)) && UNEXPECTED(EG(exception))) {
3816+
FREE_OP2();
3817+
HANDLE_EXCEPTION();
3818+
}
3819+
38103820
func = fcc.function_handler;
38113821
object_or_called_scope = fcc.called_scope;
38123822
if (func->common.fn_flags & ZEND_ACC_CLOSURE) {

Zend/zend_vm_execute.h

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)