[GIT-PULLS] [php-src] PR #22764: Fix GH-GH-22763: Clear ZREG_TYPE_ONLY flag for in-register vars in zend_jit_snapshot_handler()

[email protected] (arnaud-lb) Thu, 16 Jul 2026 14:08:54 +0000
Newsgroups php.git-pulls
Message-ID <[email protected]>
Pull Request: https://github.com/php/php-src/pull/22764
Author: arnaud-lb

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().