[php-src] master: ext/opcache: Fix JIT ignoring exceptions from typed property set hooks

From: Date: Sat, 31 Oct 2026 16:05:10 +0000
Subject: [php-src] master: ext/opcache: Fix JIT ignoring exceptions from typed property set hooks
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143079@lists.php.net to get a copy of this message
Author: David Carlier (devnexen) Date: 2026-10-31T16:04:46Z Commit: https://github.com/php/php-src/commit/63d183e9c1a12b5caa359c6af5885dea671d2f4a Raw diff: https://github.com/php/php-src/commit/63d183e9c1a12b5caa359c6af5885dea671d2f4a.diff ext/opcache: Fix JIT ignoring exceptions from typed property set hooks zend_may_throw_ex() didn't account for hooks on typed properties. Close GH-25075 Changed paths: A ext/opcache/tests/jit/assign_obj_007.phpt M NEWS M Zend/Optimizer/zend_inference.c Diff: diff --git a/NEWS b/NEWS index 24fd78630de3..a2550c672e1e 100644 --- a/NEWS +++ b/NEWS @@ -81,6 +81,7 @@ PHP NEWS loop-invariant addition). (Ilia Alshanetsky) . Fixed OSS-Fuzz #545352966 (default value AST of an SHM-persisted partial). (ndossche) + . Fixed JIT ignoring exceptions from typed property set hooks. (David Carlier) - PDO: . Fixed PDOStatement::getColumnMeta() reading out of bounds for an invalid diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index 047427072388..8d01ac050cf6 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -5264,6 +5264,7 @@ ZEND_API bool zend_may_throw_ex(const zend_op *opline, const zend_ssa_op *ssa_op * and the value already has this type: the old value has no destructor. * If the property holds a reference, all its type sources accept this type because they accept the current value. */ if ((prop_info->flags & (ZEND_ACC_READONLY|ZEND_ACC_PPP_SET_MASK)) + || prop_info->hooks || ZEND_TYPE_IS_COMPLEX(prop_info->type) || (type_mask & ~(MAY_BE_NULL|MAY_BE_BOOL|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING)) /* single type, this excludes bool too as a reference can exist to true or false standalone types. */ diff --git a/ext/opcache/tests/jit/assign_obj_007.phpt b/ext/opcache/tests/jit/assign_obj_007.phpt new file mode 100644 index 000000000000..3843b07e8593 --- /dev/null +++ b/ext/opcache/tests/jit/assign_obj_007.phpt @@ -0,0 +1,44 @@ +--TEST-- +JIT ASSIGN_OBJ: exception thrown by a set hook on a typed property +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +opcache.jit=tracing +opcache.jit_hot_loop=1 +opcache.jit_hot_func=1 +opcache.jit_hot_return=1 +opcache.jit_hot_side_exit=1 +--FILE-- +<?php +class Foo { + public int $test = 1 { + set(int $v) { + if ($v === 3) { + throw new Exception('hook threw'); + } + $this->test = $v; + } + } +} + +function test() { + $foo = new Foo; + for ($i = 0; $i < 10; $i++) { + $foo->test = $i; + echo $i, PHP_EOL; + } +} + +try { + test(); +} catch (Exception $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +?> +--EXPECT-- +0 +1 +2 +Exception: hook threw

« previous php.cvs (#143079) next »