Skip to content

Fix GH-23628: Tracing JIT reads undefined property slots of lazy proxies - #23640

Open
lisachenko wants to merge 1 commit into
php:PHP-8.5from
lisachenko:claude/php-8.5-issue-23628-rh2179
Open

Fix GH-23628: Tracing JIT reads undefined property slots of lazy proxies#23640
lisachenko wants to merge 1 commit into
php:PHP-8.5from
lisachenko:claude/php-8.5-issue-23628-rh2179

Conversation

@lisachenko

Copy link
Copy Markdown
Contributor

A lazy proxy keeps its own property slots IS_UNDEF|IS_PROP_LAZY even after it has been initialized, and the object handlers forward every property access to the real instance.

This caused the #23628 bug, because the tracing JIT was not aware of this in two places:

  1. When the recorded trace contained a FETCH_OBJ_R/IS/W on a known property whose slot was IS_UNDEF, the known-offset fast path was still compiled. For a lazy proxy this path never succeeds, and it deoptimized on every execution. Use the generic code path (that falls back to the object handlers for undefined slots) when the slot was IS_UNDEF at recording time. This also covers uninitialized and unset properties.

  2. During deoptimization of a failed result type guard after FETCH_OBJ_IS, an IS_UNDEF slot was turned into NULL, assuming an undefined property. For a slot flagged IS_PROP_LAZY the fetch has to be forwarded to the real instance instead, so re-execute the opline in the VM, the same way it is already done for FETCH_OBJ_R.

…roxies

A lazy proxy keeps its own property slots IS_UNDEF|IS_PROP_LAZY even after
it has been initialized, and the object handlers forward every property
access to the real instance. The tracing JIT was not aware of this in two
places:

1. When the recorded trace contained a FETCH_OBJ_R/IS/W on a known property
   whose slot was IS_UNDEF, the known-offset fast path was still compiled.
   For a lazy proxy this path never succeeds, and it deoptimized on every
   execution. Use the generic code path (that falls back to the object
   handlers for undefined slots) when the slot was IS_UNDEF at recording
   time. This also covers uninitialized and unset properties.

2. During deoptimization of a failed result type guard after FETCH_OBJ_IS,
   an IS_UNDEF slot was turned into NULL, assuming an undefined property.
   For a slot flagged IS_PROP_LAZY the fetch has to be forwarded to the
   real instance instead, so re-execute the opline in the VM, the same way
   it is already done for FETCH_OBJ_R.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ECekMqERF8jnqBxo1cXe3V
@lisachenko

Copy link
Copy Markdown
Contributor Author

For discussion: the compile-side change also routes uninitialized or unset typed properties through the generic path when the trace recorded the slot as undefined. That's a deliberate trade, since the fast path could never succeed in that state.

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