Skip to content

Commit 4a5854e

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

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
@@ -3909,6 +3909,16 @@ ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMPVAR|CV, NUM)
39093909
function_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
39103910
if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) {
39113911
ZEND_ASSERT(!error);
3912+
3913+
/* Deprecation can be emitted from zend_is_callable_ex(), which can
3914+
* invoke a user error handler and throw an exception.
3915+
* For the CONST and CV case we reuse the same exception block below
3916+
* to make sure we don't increase VM size too much. */
3917+
if (!(OP2_TYPE & (IS_TMP_VAR|IS_VAR)) && UNEXPECTED(EG(exception))) {
3918+
FREE_OP2();
3919+
HANDLE_EXCEPTION();
3920+
}
3921+
39123922
func = fcc.function_handler;
39133923
object_or_called_scope = fcc.called_scope;
39143924
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)