Skip to content

Assertion failure at Zend/zend_vm_execute.h:7469 #16799

Closed

Description

@YuanchengJiang

Description

The following code:

<?php
set_error_handler(function($_, $m) { throw new Exception($m); });
class Test1 {
static function test() {
call_user_func("static::ok");
}
}
class Test2 extends Test1 {
static function ok() {
}
}
Test2::test();

Resulted in this output:

php: Zend/zend_vm_execute.h:7469: int ZEND_INIT_USER_CALL_SPEC_CONST_CONST_HANDLER(zend_execute_data *): Assertion `!(((zend_executor_globals *) (((char*) _tsrm_ls_cache)+(executor_globals_offset)))->exception)' failed.
Aborted (core dumped)

PHP Version

nightly

Operating System

No response

Activity

  1. ndossche commented on Nov 14, 2024

    @ndossche
    Member

    Reproduces in 8.2 too.

  2. ndossche commented on Nov 14, 2024

    @ndossche
    Member

    This happens because using static in callables causes a deprecation warning in zend_is_callable_ex and the error handler unfortunately transforms that into an exception.

    Possible fix, but would have to think a bit more:

    diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
    index 2a48b9c3713..95b2b1eba19 100644
    --- a/Zend/zend_vm_def.h
    +++ b/Zend/zend_vm_def.h
    @@ -3806,6 +3806,13 @@ ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMPVAR|CV, NUM)
     	SAVE_OPLINE();
     	function_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
     	if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) {
    +		/* Deprecation can be emitted from zend_is_callable_ex(), and then
    +		 * transformed into an exception. */
    +		if (UNEXPECTED(EG(exception))) {
    +			FREE_OP2();
    +			HANDLE_EXCEPTION();
    +		}
    +
     		ZEND_ASSERT(!error);
     		func = fcc.function_handler;
     		object_or_called_scope = fcc.called_scope;
    diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
    index 3bc01a597fa..ef49815ee44 100644
    --- a/Zend/zend_vm_execute.h
    +++ b/Zend/zend_vm_execute.h
    @@ -7022,6 +7022,13 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_CONS
     	SAVE_OPLINE();
     	function_name = RT_CONSTANT(opline, opline->op2);
     	if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) {
    +		/* Deprecation can be emitted from zend_is_callable_ex(), and then
    +		 * transformed into an exception. */
    +		if (UNEXPECTED(EG(exception))) {
    +
    +			HANDLE_EXCEPTION();
    +		}
    +
     		ZEND_ASSERT(!error);
     		func = fcc.function_handler;
     		object_or_called_scope = fcc.called_scope;
    @@ -9367,6 +9374,13 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_TMPV
     	SAVE_OPLINE();
     	function_name = _get_zval_ptr_var(opline->op2.var EXECUTE_DATA_CC);
     	if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) {
    +		/* Deprecation can be emitted from zend_is_callable_ex(), and then
    +		 * transformed into an exception. */
    +		if (UNEXPECTED(EG(exception))) {
    +			zval_ptr_dtor_nogc(EX_VAR(opline->op2.var));
    +			HANDLE_EXCEPTION();
    +		}
    +
     		ZEND_ASSERT(!error);
     		func = fcc.function_handler;
     		object_or_called_scope = fcc.called_scope;
    @@ -11741,6 +11755,13 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_CV_H
     	SAVE_OPLINE();
     	function_name = _get_zval_ptr_cv_BP_VAR_R(opline->op2.var EXECUTE_DATA_CC);
     	if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) {
    +		/* Deprecation can be emitted from zend_is_callable_ex(), and then
    +		 * transformed into an exception. */
    +		if (UNEXPECTED(EG(exception))) {
    +
    +			HANDLE_EXCEPTION();
    +		}
    +
     		ZEND_ASSERT(!error);
     		func = fcc.function_handler;
     		object_or_called_scope = fcc.called_scope;
    
  3. added 2 commits that reference this issue on Nov 15, 2024
    553d79c
    ed59c00
  4. added 2 commits that reference this issue on Nov 15, 2024
    4a5854e
    4c88bfb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions