Skip to content

Fix GH-21770: Infinite recursion in property hook getter in opcache preloaded trait#21788

Open
iliaal wants to merge 1 commit intophp:PHP-8.4from
iliaal:fix/gh21770-trait-hook-preload-prop-info
Open

Fix GH-21770: Infinite recursion in property hook getter in opcache preloaded trait#21788
iliaal wants to merge 1 commit intophp:PHP-8.4from
iliaal:fix/gh21770-trait-hook-preload-prop-info

Conversation

@iliaal
Copy link
Copy Markdown
Contributor

@iliaal iliaal commented Apr 17, 2026

Fixes #21770.

preload_fix_trait_op_array rewrites trait-cloned op_arrays from their original after optimization and preserves a short allowlist of per-clone fields: function_name, scope, fn_flags, prototype, static_variables. For trait-cloned property hooks, prop_info is also per-clone. zend_do_traits_property_binding points it at the using class's property, and zend_is_in_hook relies on that identity to detect backing-store access from inside the hook. Without restoring prop_info, the rewrite pointed it back at the trait's property, prototypes mismatched, and reading or writing the backing store from inside the hook recursed into the hook instead.

Restoring prop_info alongside the other preserved fields fixes the mismatch and the runaway recursion.

…e preloaded trait

preload_fix_trait_op_array rewrites the clone op_array from its original
after optimization, preserving function_name, scope, fn_flags, prototype,
and static_variables. For trait-cloned property hooks, it also needs to
preserve prop_info: zend_do_traits_property_binding set it to the using
class's property, but the reset pointed it back at the trait's property.
That mismatch caused zend_is_in_hook to miss the self-access check inside
the hook, recursing into the getter/setter instead of reading or writing
the backing store.

Closes phpGH-21770
@iliaal
Copy link
Copy Markdown
Contributor Author

iliaal commented Apr 17, 2026

@iluuu1994 Just got around to validating my take on it, a bit late since I saw you assigned it to yourself, hopefully proves useful and doesn't duplicate too much effort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant