[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
| From: | Ilija Tovilo | Date: | Wed, 18 Nov 2026 16:12:46 +0000 |
| Subject: | [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143838@lists.php.net to get a copy of this message | ||
Author: Ilija Tovilo (iluuu1994)
Date: 2026-11-18T17:12:11+01:00
Commit: https://github.com/php/php-src/commit/31d6bd6f653c796e5db285ed7b66fece2622ccc4
Raw diff: https://github.com/php/php-src/commit/31d6bd6f653c796e5db285ed7b66fece2622ccc4.diff
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
Revert "Zend: delayed OOM clears the opline of a frame mid-op."
Changed paths:
D ext/opcache/tests/jit/gh25304.phpt
M Zend/zend_alloc.c
M Zend/zend_vm_def.h
M Zend/zend_vm_execute.h
M ext/opcache/jit/zend_jit_ir.c
Diff:
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 358d89188ca7..5a529ff08e37 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -3929,6 +3929,11 @@ ZEND_API void ZEND_FASTCALL zend_handle_delayed_oom(void)
/* Bailout discards EG(current_execute_data). Would be better to avoid the bailout here. */
EG(current_execute_data) = execute_data;
+ /* This function may be called from the VM interrupt handler: opline is not
+ * executed yet. Set opline_before_exception to NULL so
+ * ZEND_HANDLE_EXCEPTION does not use it. */
+ EG(opline_before_exception) = NULL;
+
zend_mm_oom_info_dtor(info);
info->state = ZEND_OOM_STATE_HANDLED;
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 4c9d0cb2c8d6..0a96afdb3dcf 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -8186,7 +8186,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
const zend_op *throw_op = EG(opline_before_exception);
/* Exception was thrown before executing any op, or between two ops (see
- * zend_interrupt_helper). */
+ * zend_handle_delayed_oom()). */
if (UNEXPECTED(!throw_op)) {
free_unfinished_calls(execute_data);
ZEND_VM_DISPATCH_TO_HELPER(zend_dispatch_try_catch_finally_helper, try_catch_offset, -1, op_num,
-1);
@@ -10555,7 +10555,6 @@ ZEND_VM_HELPER(zend_interrupt_helper, ANY, ANY)
zend_timeout();
} else if (ZEND_HAS_OOM()) {
zend_handle_delayed_oom();
- EG(opline_before_exception) = NULL;
HANDLE_EXCEPTION();
} else if (zend_interrupt_function) {
zend_interrupt_function(execute_data);
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 1ba4692db829..dd00d04f6bcb 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -3394,7 +3394,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV
ZEND_HANDLE_EXCEPT
const zend_op *throw_op = EG(opline_before_exception);
/* Exception was thrown before executing any op, or between two ops (see
- * zend_interrupt_helper). */
+ * zend_handle_delayed_oom()). */
if (UNEXPECTED(!throw_op)) {
free_unfinished_calls(execute_data);
ZEND_VM_DISPATCH_TO_HELPER(zend_dispatch_try_catch_finally_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_EX
-1, -1));
@@ -4040,7 +4040,6 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET
ZEND_OPCODE_HANDLER_FUNC_CCONV
zend_timeout();
} else if (ZEND_HAS_OOM()) {
zend_handle_delayed_oom();
- EG(opline_before_exception) = NULL;
HANDLE_EXCEPTION();
} else if (zend_interrupt_function) {
zend_interrupt_function(execute_data);
@@ -59133,7 +59132,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV
ZEND_HANDLE_EXCEPTION_S
const zend_op *throw_op = EG(opline_before_exception);
/* Exception was thrown before executing any op, or between two ops (see
- * zend_interrupt_helper). */
+ * zend_handle_delayed_oom()). */
if (UNEXPECTED(!throw_op)) {
free_unfinished_calls(execute_data);
ZEND_VM_DISPATCH_TO_HELPER(zend_dispatch_try_catch_finally_helper_SPEC_TAILCALL(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_EX
-1, -1));
@@ -59779,7 +59778,6 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV
zend
zend_timeout();
} else if (ZEND_HAS_OOM()) {
zend_handle_delayed_oom();
- EG(opline_before_exception) = NULL;
HANDLE_EXCEPTION();
} else if (zend_interrupt_function) {
zend_interrupt_function(execute_data);
diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c
index 9b03a4e6a7e2..4fab838d9caa 100644
--- a/ext/opcache/jit/zend_jit_ir.c
+++ b/ext/opcache/jit/zend_jit_ir.c
@@ -2097,7 +2097,6 @@ static int zend_jit_interrupt_handler_stub(zend_jit_ctx *jit)
ir_ref if_delayed_oom = ir_IF(ir_LOAD_U8(ir_ADD_OFFSET(jit_EG(delayed_oom),
offsetof(zend_oom_info, state))));
ir_IF_TRUE(if_delayed_oom);
ir_CALL(IR_VOID, ir_CONST_FC_FUNC(zend_handle_delayed_oom));
- ir_STORE(jit_EG(opline_before_exception), IR_NULL);
// LOAD_OPLINE()
jit_STORE_IP(jit, ir_LOAD_A(jit_EX(opline)));
ir_ref if_delayed_oom_end = ir_END();
diff --git a/ext/opcache/tests/jit/gh25304.phpt b/ext/opcache/tests/jit/gh25304.phpt
deleted file mode 100644
index 3eddda9f4db9..000000000000
--- a/ext/opcache/tests/jit/gh25304.phpt
+++ /dev/null
@@ -1,29 +0,0 @@
---TEST--
-GH-25304 (JIT: SEGV in exception handler stub after OOM inside an output-buffer callback)
---CREDITS--
-YuanchengJiang
---EXTENSIONS--
-opcache
---SKIPIF--
-<?php
-if (getenv("USE_ZEND_ALLOC") === "0") die("skip Zend MM disabled");
-?>
---INI--
-memory_limit=16M
-opcache.enable=1
-opcache.enable_cli=1
-opcache.jit=function
-opcache.jit_buffer_size=64M
---FILE--
-<?php
-$o = new stdClass;
-ob_start(function ($buffer) use (&$storage) {
- $storage .= $buffer;
- return '';
-}, 1);
-while ($o < 10);
-?>
---EXPECTF--
-Notice: Object of class stdClass could not be converted to int in %s on line %d
-
-Fatal error: Allowed memory size of %d bytes exhausted%S(tried to allocate %d bytes) in %s on line
%d