[php-src] PHP-8.6: Fix assertion in VM when taking ref-returning fcall by-value

From: Date: Fri, 30 Oct 2026 14:34:32 +0000
Subject: [php-src] PHP-8.6: Fix assertion in VM when taking ref-returning fcall by-value
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143007@lists.php.net to get a copy of this message
Author: Bob Weinand (bwoebi) Date: 2026-10-30T15:34:17+01:00 Commit: https://github.com/php/php-src/commit/8fc9e7c8e8f771ab55671cec00c4e468ec511efe Raw diff: https://github.com/php/php-src/commit/8fc9e7c8e8f771ab55671cec00c4e468ec511efe.diff Fix assertion in VM when taking ref-returning fcall by-value zend_return_unwrap_ref() is expected to be called now, but internal functions returning by reference were failing the debug assertion, expecting that they would unconditionally return by reference. Adjusted the assertion. Signed-off-by: Bob Weinand <bobwei9@hotmail.com> Changed paths: M Zend/zend_execute.c M Zend/zend_execute.h M Zend/zend_execute_API.c M Zend/zend_vm_def.h M Zend/zend_vm_execute.h M ext/zend_test/test.c M ext/zend_test/test.stub.php M ext/zend_test/test_arginfo.h M ext/zend_test/test_decl.h M ext/zend_test/test_legacy_arginfo.h Diff: diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 3133caea2e08..e929bc41a03d 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -6004,26 +6004,7 @@ ZEND_API zval *zend_get_zval_ptr(const zend_op *opline, int op_type, const znode ZEND_API void zend_return_unwrap_ref(zend_execute_data *execute_data, zval *return_value) { - if (!return_value || !Z_ISREF_P(return_value)) { - return; - } - - zend_execute_data *prev_ex = EX(prev_execute_data); - if (!prev_ex || !prev_ex->func || !ZEND_USER_CODE(prev_ex->func->type)) { - return; + if (return_value && Z_ISREF_P(return_value) && zend_return_should_unwrap_ref(execute_data)) { + zend_unwrap_reference(return_value); } - - const zend_op *do_opline = prev_ex->opline; - if (do_opline->result_type != IS_TMP_VAR) { - return; - } - - if (do_opline->opcode != ZEND_DO_FCALL - && do_opline->opcode != ZEND_DO_FCALL_BY_NAME - && do_opline->opcode != ZEND_DO_ICALL - && do_opline->opcode != ZEND_DO_UCALL) { - return; - } - - zend_unwrap_reference(return_value); } diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 14c1e6701f09..bdb4f66cb2f6 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -676,6 +676,24 @@ static zend_always_inline void *zend_get_bad_ptr(void) return NULL; } +static zend_always_inline bool zend_return_should_unwrap_ref(const zend_execute_data *call) +{ + const zend_execute_data *prev_ex = call->prev_execute_data; + if (!prev_ex || !prev_ex->func || !ZEND_USER_CODE(prev_ex->func->type)) { + return false; + } + + const zend_op *do_opline = prev_ex->opline; + if (do_opline->result_type != IS_TMP_VAR) { + return false; + } + + return do_opline->opcode == ZEND_DO_FCALL + || do_opline->opcode == ZEND_DO_FCALL_BY_NAME + || do_opline->opcode == ZEND_DO_ICALL + || do_opline->opcode == ZEND_DO_UCALL; +} + ZEND_API void zend_return_unwrap_ref(zend_execute_data *call, zval *return_value); END_EXTERN_C() diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index b9e992ff8a0e..2c361bb49509 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1106,7 +1106,7 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_ bool result = zend_verify_internal_return_type(call->func, fci->retval); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(fci->retval) : !Z_ISREF_P(fci->retval)); ZEND_ASSERT(!(call->func->common.fn_flags2 & ZEND_ACC2_FORBID_DYN_CALLS)); } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 4375b7ad3f31..b3d0597374c0 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -4158,7 +4158,7 @@ ZEND_VM_HOT_HANDLER(129, ZEND_DO_ICALL, ANY, ANY, SPEC(RETVAL,OBSERVER)) bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -4291,7 +4291,7 @@ ZEND_VM_HOT_HANDLER(131, ZEND_DO_FCALL_BY_NAME, ANY, ANY, SPEC(RETVAL,OBSERVER)) bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -4424,7 +4424,7 @@ ZEND_VM_HOT_HANDLER(60, ZEND_DO_FCALL, ANY, ANY, SPEC(RETVAL,OBSERVER)) bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -9182,7 +9182,7 @@ ZEND_VM_HANDLER(158, ZEND_CALL_TRAMPOLINE, ANY, ANY, SPEC(OBSERVER)) bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 59891e70d9aa..74ed43010473 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1331,7 +1331,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_D bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -1401,7 +1401,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_D bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -1471,7 +1471,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_ bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -1657,7 +1657,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_D bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -1775,7 +1775,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_D bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -1892,7 +1892,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_ bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -2028,7 +2028,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_D bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -2163,7 +2163,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_D bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -2295,7 +2295,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_ bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -3686,7 +3686,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_CALL_TRAMPOLI bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -3834,7 +3834,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_CALL_TRAMPOLI bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -54326,7 +54326,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_ICA bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -54396,7 +54396,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_ICA bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -54466,7 +54466,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_IC bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -54652,7 +54652,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_FCA bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -54770,7 +54770,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_FCA bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -54887,7 +54887,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_FC bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -55023,7 +55023,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_FCA bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -55158,7 +55158,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_FCA bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -55290,7 +55290,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_DO_FC bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -56565,7 +56565,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_CALL_TRAMPOLINE_SP bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) @@ -56713,7 +56713,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_CALL_TRAMPOLINE_SP bool result = zend_verify_internal_return_type(call->func, ret); ZEND_ASSERT(result); } - ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) + ZEND_ASSERT(((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) && !zend_return_should_unwrap_ref(call)) ? Z_ISREF_P(ret) : !Z_ISREF_P(ret)); zend_verify_internal_func_info(call->func, ret); ZEND_ASSERT(!(ZEND_CALL_INFO(call) & ZEND_CALL_DYNAMIC) diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index c1ede5c60437..02f09a5a7ab8 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -132,6 +132,18 @@ static void pass2(zend_script *script, void *context) php_printf("pass2\n"); } +static ZEND_FUNCTION(zend_test_forward_reference) +{ + zval *value; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + + ZVAL_COPY(return_value, value); + zend_return_unwrap_ref(execute_data, return_value); +} + static ZEND_FUNCTION(zend_test_deprecated) { zval *arg1; diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index 8137b911a352..8719c6935a33 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -265,6 +265,8 @@ function zend_test_nullable_array_return(): null|array {} function zend_test_void_return(): void {} + function &zend_test_forward_reference(mixed &$value): mixed {} + function zend_test_compile_string(string $source_string, string $filename, int $position): void {} /** @deprecated */ diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index 184bcdbae147..d6fa8896c42b 100644 --- a/ext/zend_test/test_arginfo.h +++ b/ext/zend_test/test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: a49cfced20b16588283149be5d01212924c925fd + * Stub hash: 55bb2e6d209ea4030e3edfd604fc5ce4d14267f0 * Has decl header: yes */ #include "zend_attributes.h" @@ -20,6 +20,10 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_void_return, 0, 0, IS_VOID, 0) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_forward_reference, 1, 1, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(1, value, IS_MIXED, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_compile_string, 0, 3, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, source_string, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -457,6 +461,7 @@ static ZEND_FUNCTION(zend_trigger_bailout); static ZEND_FUNCTION(zend_test_array_return); static ZEND_FUNCTION(zend_test_nullable_array_return); static ZEND_FUNCTION(zend_test_void_return); +static ZEND_FUNCTION(zend_test_forward_reference); static ZEND_FUNCTION(zend_test_compile_string); static ZEND_FUNCTION(zend_test_deprecated); static ZEND_FUNCTION(zend_test_deprecated_attr); @@ -606,6 +611,7 @@ static const zend_function_entry ext_functions[] = { #endif #endif ZEND_FE(zend_test_void_return, arginfo_zend_test_void_return) + ZEND_FE(zend_test_forward_reference, arginfo_zend_test_forward_reference) ZEND_FE(zend_test_compile_string, arginfo_zend_test_compile_string) #if (PHP_VERSION_ID >= 80400) ZEND_RAW_FENTRY("zend_test_deprecated", zif_zend_test_deprecated, arginfo_zend_test_deprecated, ZEND_ACC_DEPRECATED, NULL, NULL) diff --git a/ext/zend_test/test_decl.h b/ext/zend_test/test_decl.h index cab05e40a40b..35e929d1a306 100644 --- a/ext/zend_test/test_decl.h +++ b/ext/zend_test/test_decl.h @@ -1,8 +1,8 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: a49cfced20b16588283149be5d01212924c925fd */ + * Stub hash: 55bb2e6d209ea4030e3edfd604fc5ce4d14267f0 */ -#ifndef ZEND_TEST_DECL_a49cfced20b16588283149be5d01212924c925fd_H -#define ZEND_TEST_DECL_a49cfced20b16588283149be5d01212924c925fd_H +#ifndef ZEND_TEST_DECL_55bb2e6d209ea4030e3edfd604fc5ce4d14267f0_H +#define ZEND_TEST_DECL_55bb2e6d209ea4030e3edfd604fc5ce4d14267f0_H typedef enum zend_enum_ZendTestUnitEnum { ZEND_ENUM_ZendTestUnitEnum_Foo = 1, @@ -27,4 +27,4 @@ typedef enum zend_enum_ZendTestEnumWithInterface { ZEND_ENUM_ZendTestEnumWithInterface_Bar = 2, } zend_enum_ZendTestEnumWithInterface; -#endif /* ZEND_TEST_DECL_a49cfced20b16588283149be5d01212924c925fd_H */ +#endif /* ZEND_TEST_DECL_55bb2e6d209ea4030e3edfd604fc5ce4d14267f0_H */ diff --git a/ext/zend_test/test_legacy_arginfo.h b/ext/zend_test/test_legacy_arginfo.h index d58dc5d26220..9bb20c85e95a 100644 --- a/ext/zend_test/test_legacy_arginfo.h +++ b/ext/zend_test/test_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit test.stub.php instead. - * Stub hash: a49cfced20b16588283149be5d01212924c925fd + * Stub hash: 55bb2e6d209ea4030e3edfd604fc5ce4d14267f0 * Has decl header: yes */ #include "zend_constants.h" @@ -16,6 +16,10 @@ ZEND_END_ARG_INFO() #define arginfo_zend_test_void_return arginfo_zend_trigger_bailout +ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_test_forward_reference, 0, 1, 1) + ZEND_ARG_INFO(1, value) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_zend_test_compile_string, 0, 0, 3) ZEND_ARG_INFO(0, source_string) ZEND_ARG_INFO(0, filename) @@ -381,6 +385,7 @@ static ZEND_FUNCTION(zend_trigger_bailout); static ZEND_FUNCTION(zend_test_array_return); static ZEND_FUNCTION(zend_test_nullable_array_return); static ZEND_FUNCTION(zend_test_void_return); +static ZEND_FUNCTION(zend_test_forward_reference); static ZEND_FUNCTION(zend_test_compile_string); static ZEND_FUNCTION(zend_test_deprecated); static ZEND_FUNCTION(zend_test_deprecated_attr); @@ -522,6 +527,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_test_array_return, arginfo_zend_test_array_return) ZEND_FE(zend_test_nullable_array_return, arginfo_zend_test_nullable_array_return) ZEND_FE(zend_test_void_return, arginfo_zend_test_void_return) + ZEND_FE(zend_test_forward_reference, arginfo_zend_test_forward_reference) ZEND_FE(zend_test_compile_string, arginfo_zend_test_compile_string) #if (PHP_VERSION_ID >= 80400) ZEND_RAW_FENTRY("zend_test_deprecated", zif_zend_test_deprecated, arginfo_zend_test_deprecated, ZEND_ACC_DEPRECATED, NULL, NULL)

« previous php.cvs (#143007) next »