Skip to content
Closed
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: 1 addition & 4 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -10221,10 +10221,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen
&& ZEND_MAP_PTR_IS_OFFSET(func->op_array.run_time_cache)) {
run_time_cache = ir_LOAD_A(ir_ADD_OFFSET(ir_LOAD_A(jit_CG(map_ptr_base)),
(uintptr_t)ZEND_MAP_PTR(func->op_array.run_time_cache)));
} else if ((func && (func->op_array.fn_flags & ZEND_ACC_CLOSURE)) ||
(JIT_G(current_frame) &&
JIT_G(current_frame)->call &&
TRACE_FRAME_IS_CLOSURE_CALL(JIT_G(current_frame)->call))) {
} else if (func && (func->op_array.fn_flags & ZEND_ACC_CLOSURE)) {
/* Closures always use direct pointers */
ir_ref local_func_ref = func_ref ? func_ref : ir_LOAD_A(jit_CALL(rx, func));

Expand Down
57 changes: 57 additions & 0 deletions ext/opcache/tests/jit/gh22443.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
--TEST--
GH-22443 (SIGSEGV in tracing JIT: run_time_cache offset stored without map_ptr dereference)
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.jit=tracing
opcache.jit_buffer_size=64M
opcache.jit_max_polymorphic_calls=0
--FILE--
<?php
final class Svc {
public function m0(...$a): int { return (int) array_sum($a) + 0; }
public function m1(...$a): int { return (int) array_sum($a) + 1; }
public function m2(...$a): int { return (int) array_sum($a) + 2; }
public function m3(...$a): int { return (int) array_sum($a) + 3; }
public function m4(...$a): int { return (int) array_sum($a) + 4; }
public function m5(...$a): int { return (int) array_sum($a) + 5; }
public function m6(...$a): int { return (int) array_sum($a) + 6; }
public function m7(...$a): int { return (int) array_sum($a) + 7; }
public function coldMethod(...$a): int { return $this->helper((int) array_sum($a)); }
private function helper(int $x): int { return $x + 1; }
}

function makeListener($listener): Closure {
return function ($event, $payload) use ($listener) {
return $listener(...array_values($payload));
};
}

function invokeListeners(array $listeners, string $event, array $payload): int {
$r = 0;
foreach ($listeners as $l) {
$r += $l($event, $payload);
}
return $r;
}

$svc = new Svc();
$warm = [];
for ($k = 0; $k < 8; $k++) {
$warm[] = makeListener([$svc, 'm' . $k]);
}
$cold = [makeListener([$svc, 'coldMethod'])];

$s = 0;
for ($i = 0; $i < 4000000; $i++) {
$s += invokeListeners($warm, 'e', [$i & 7, ($i >> 2) & 7]);
}
for ($j = 0; $j < 5; $j++) {
$s += invokeListeners($cold, 'e', [$j, $j + 1]);
}
echo "done\n";
?>
--EXPECT--
done
Loading