Skip to content

Fix GH-22763: Clear ZREG_TYPE_ONLY flag for in-register vars in zend_jit_snapshot_handler()#22764

Open
arnaud-lb wants to merge 1 commit into
php:PHP-8.5from
arnaud-lb:gh22763
Open

Fix GH-22763: Clear ZREG_TYPE_ONLY flag for in-register vars in zend_jit_snapshot_handler()#22764
arnaud-lb wants to merge 1 commit into
php:PHP-8.5from
arnaud-lb:gh22763

Conversation

@arnaud-lb

Copy link
Copy Markdown
Member

Fixes GH-22763.

The reproducer triggers an assertion in zend_jit_use_reg() because a var has jit->ra[var].ref == IR_NULL but jit->ra[var].flags doesn't contain ZREG_LOAD.

This happens because of the following events:

  • An in-register variable is spilled to the VM stack frame by IR (IR_REG_SPILL_SPECIAL)
  • zend_jit_snapshot_handler() set the stack descriptor to .flags = ZREG_TYPE_ONLY, .reg = ZREG_NONE
  • During a subsequent call to zend_jit_snapshot_handler(), the reg is not IR_REG_SPILL_SPECIAL anymore, so .reg is set but .flags remains ZREG_TYPE_ONLY which is inconsistent
  • A side trace inherits from this stack descriptor
  • zend_jit_trace_deoptimization() doesn't set jit->ra[var].ref for this var because .flags == ZREG_TYPE_ONLY, which causes the assertion failure later

Fix by removing irrelevant flags when setting reg in zend_jit_snapshot_handler().

@arnaud-lb arnaud-lb changed the title Fix GH-GH-22763: Clear ZREG_TYPE_ONLY flag for in-register vars in zend_jit_snapshot_handler() Fix GH-22763: Clear ZREG_TYPE_ONLY flag for in-register vars in zend_jit_snapshot_handler() Jul 16, 2026
@arnaud-lb
arnaud-lb marked this pull request as ready for review July 16, 2026 17:42
@arnaud-lb
arnaud-lb requested a review from dstogov as a code owner July 16, 2026 17:42
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