Skip to content

Commit 4c88bfb

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-16799: Assertion failure at Zend/zend_vm_execute.h:7469
2 parents b7165f5 + 4a5854e commit 4c88bfb

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

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
@@ -3918,6 +3918,16 @@ ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMPVAR|CV, NUM)
39183918
function_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
39193919
if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) {
39203920
ZEND_ASSERT(!error);
3921+
3922+
/* Deprecation can be emitted from zend_is_callable_ex(), which can
3923+
* invoke a user error handler and throw an exception.
3924+
* For the CONST and CV case we reuse the same exception block below
3925+
* to make sure we don't increase VM size too much. */
3926+
if (!(OP2_TYPE & (IS_TMP_VAR|IS_VAR)) && UNEXPECTED(EG(exception))) {
3927+
FREE_OP2();
3928+
HANDLE_EXCEPTION();
3929+
}
3930+
39213931
func = fcc.function_handler;
39223932
object_or_called_scope = fcc.called_scope;
39233933
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)