You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Assertion in ZEND_DO_FCALL: reference returned by &__get() reaches property hook TMP result #25314
<?phpclass P {
publicint$d = 1;
function &__get($name) {}
}
class C extends P {
publicint$d = 2 { get => parent::$d::get(); }
}
classGCextends C {
publicint$d { get => parent::$d::get(); }
}
var_dump((newGC)->d);
Hi, while re-testing property hook trampolines on 8.5.13 (46bcb66) I can confirm this defect is still present in the 8.5 stable line, in a form the official test does not catch. The gh25314.phpt passes on release builds because a TypeError masks the defect path before it is reached (the assert is debug-only).
With a non-typed hook and a &__get() that returns an object from a static array, the value returned through the parent hook get trampoline (zend_object_handlers.c:1840-1845, RETVAL_COPY without deref) is silently detached, so writes through $x land on a copy and the original data is lost:
class P { static$v = ['k' => 'sensitivedata'];
function &__get($name) { returnself::$v; } }
class C extends P { public$d = 2 { get => parent::$d::get(); } }
classGCextends C { public$d { get => parent::$d::get(); } }
$x = (newGC)->d; // should be a reference to P::$v$x['injected'] = 'X'; // lands on a detached copyvar_dump($x); // ["injected"]=> "X" -- the original "k" is gonevar_dump(P::$v); // unchanged
The fix on master (9afb81f) is not in 8.5.13. Hope this helps.
Thanks - you are right. The = 2 default value on the get-only hooked property was unintentionally left in from an earlier variant of the reproducer, and it is exactly what trips the "Cannot specify default value for virtual hooked property" check on the branch heads. Here is a default-free version; this is also the form I would like to ask about.
<?phpclass P {
public$d = 1;
static$v = ['k' => 'sensitivedata'];
function &__get($name) { returnself::$v; }
}
class C extends P {
public$d { get => parent::$d::get(); }
}
classGCextends C {
public$d { get => parent::$d::get(); }
}
$x = (newGC)->d; // trampoline: parent::$d::get() twice, ending at the &__get() reference$x['injected'] = 'X';
var_dump($x);
var_dump(P::$v);
Observed (release-style builds: ./configure --disable-all --enable-cli), all on 2026-11-22:
PHP 8.5.13 (46bcb66): runs without error. $x ends up as array(1) { ["injected"]=> "X" } - the original "k" is silently missing from the returned value - and P::$v is untouched (["k"] only). The write did not go through the reference and the read did not return the referenced value.
PHP-8.5 head (e8585b8, 8.5.14-dev): same silent loss.
master (d190cfe, 8.7.0-dev, includes 9afb81f): same silent loss.
So on 8.5 stable the write-through failure through the parent hook trampoline still reproduces after your fix removed the assertion/UAF symptom; on master the same script no longer crashes but the value returned through the parent::$d::get() chain is an empty array rather than the referenced ['k']. Could you confirm whether losing the referenced value through parent::$prop::get() chains is intended post-9afb81f60, or a remaining gap of this issue?
If it is useful as a separate report: the value loss through parent::$prop::get() also reproduces without any __get() involvement, on a plain parent property, in a two-line hierarchy:
<?phpclass P { public$d = 1; }
class C extends P { public$d { get => parent::$d::get(); } }
var_dump((newC)->d); // NULL on 8.5.13 / PHP-8.5 head / PHP-8.6 head / master - expected int(1)
and with a declared default on the child, parent::$d::get() returns the child's default instead of the parent's value (public $d = 9 { get => parent::$d::get() + 100; } gives int(109) instead of int(101)). I can file that separately if you prefer.
Sounds good - we won't file the parent::$prop::get() value-loss observation separately; whether it deserves its own issue is up to you.
All the reproducers above (the default-free version, the two-level variant, and the + 100 variant that shows parent::$d::get() resolving to the child's declared default instead of the parent's value) are self-contained, so feel free to use them when working on the general fix. Thanks for looking into it.
Activity
ndossche commentedon Nov 8, 2026
Only reproduces in 8.6+.
Fix phpGH-25314: Assertion in ZEND_DO_FCALL: reference returned by &_…
Merge branch 'PHP-8.6'
lhjnano commentedon Nov 20, 2026
Hi, while re-testing property hook trampolines on 8.5.13 (46bcb66) I can confirm this defect is still present in the 8.5 stable line, in a form the official test does not catch. The gh25314.phpt passes on release builds because a TypeError masks the defect path before it is reached (the assert is debug-only).
With a non-typed hook and a
&__get()that returns an object from a static array, the value returned through the parent hook get trampoline (zend_object_handlers.c:1840-1845, RETVAL_COPY without deref) is silently detached, so writes through$xland on a copy and the original data is lost:The fix on master (9afb81f) is not in 8.5.13. Hope this helps.
ndossche commentedon Nov 22, 2026
@lhjnano
Your reproducer triggers an error on 8.6 & 8.5:
Please provide a working reproducer.
lhjnano commentedon Nov 22, 2026
Hi Nora,
Thanks - you are right. The
= 2default value on the get-only hooked property was unintentionally left in from an earlier variant of the reproducer, and it is exactly what trips the "Cannot specify default value for virtual hooked property" check on the branch heads. Here is a default-free version; this is also the form I would like to ask about.Observed (release-style builds: ./configure --disable-all --enable-cli), all on 2026-11-22:
$xends up asarray(1) { ["injected"]=> "X" }- the original"k"is silently missing from the returned value - andP::$vis untouched (["k"]only). The write did not go through the reference and the read did not return the referenced value.So on 8.5 stable the write-through failure through the parent hook trampoline still reproduces after your fix removed the assertion/UAF symptom; on master the same script no longer crashes but the value returned through the
parent::$d::get()chain is an empty array rather than the referenced['k']. Could you confirm whether losing the referenced value throughparent::$prop::get()chains is intended post-9afb81f60, or a remaining gap of this issue?If it is useful as a separate report: the value loss through
parent::$prop::get()also reproduces without any__get()involvement, on a plain parent property, in a two-line hierarchy:and with a declared default on the child,
parent::$d::get()returns the child's default instead of the parent's value (public $d = 9 { get => parent::$d::get() + 100; }givesint(109)instead ofint(101)). I can file that separately if you prefer.lhjnano commentedon Nov 22, 2026
Sounds good - we won't file the parent::$prop::get() value-loss observation separately; whether it deserves its own issue is up to you.
All the reproducers above (the default-free version, the two-level variant, and the
+ 100variant that shows parent::$d::get() resolving to the child's declared default instead of the parent's value) are self-contained, so feel free to use them when working on the general fix. Thanks for looking into it.