Skip to content

Fix GH-24397: Clear vacated MERGE inputs in _zend_jit_fix_merges() - #24419

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/gh-24397-jit-fix-merges-stale-inputs
Open

iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/gh-24397-jit-fix-merges-stale-inputs

Conversation

@iliaal

@iliaal iliaal commented Oct 18, 2026

Copy link
Copy Markdown
Member

_zend_jit_fix_merges() compacts a MERGE's live inputs to the left without clearing the slots it vacates. When one input survives, the node becomes a BEGIN whose op2 is a label operand, so the stale END ref is read as a label: ir_save() asserts on it in debug builds when opcache.jit_debug sets an IR dump bit, and in all builds the aliasing load and store searches treat the block as address-taken and stop there. PHI compaction reads only up to inputs_count, and the PHI-to-COPY conversion already overwrites op2.

Fixes #24397

_zend_jit_fix_merges() compacts the non-zero inputs of a MERGE or
LOOP_BEGIN to the left but left the vacated slots holding their old refs.
When a single input survives, the node becomes a BEGIN whose op2 is a
label operand, so the stale END ref was read as a label: ir_save()
asserted on it, and the aliasing load and store searches stopped at the
block as if its address were taken. PHI inputs are compacted the same way
but are bounded by inputs_count, and a PHI reduced to COPY already
overwrites op2.

Fixes phpGH-24397

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you fix the thing you've been asked to fix on Slack before submitting more PRs?

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.

2 participants