Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Zend/zend_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3680,11 +3680,6 @@ 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;

Expand Down
3 changes: 2 additions & 1 deletion Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -8141,7 +8141,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_handle_delayed_oom()). */
* zend_interrupt_helper). */
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);
Expand Down Expand Up @@ -10437,6 +10437,7 @@ 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);
Expand Down
3 changes: 2 additions & 1 deletion Zend/zend_vm_execute.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,7 @@ 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();
Expand Down
29 changes: 29 additions & 0 deletions ext/opcache/tests/jit/gh25304.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--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
Loading