Skip to content

Commit 72cbb07

Browse files
committed
refcount_insertion: fix model reg mismatch in env bit assignment
Env initialization used hir_chase_assign (only follows Assign instrs) to compute model registers for support bit assignment. But the pass processing uses phx_rc_model_reg (follows ALL passthroughs except GuardIs). When a phi input goes through a non-Assign passthrough (CheckField, CheckVar, etc.), the two functions return different model registers. The env assigns a bit for the chase_assign model, but the pass looks up using the modelReg model — returning -1 (not found). This -1 was then cast to size_t (becoming SIZE_MAX) and passed to phx_bv_set_bit, causing out-of-bounds memory access → SIGSEGV. Fix: use phx_rc_model_reg in env initialization, matching the pass. Bug python#17: triggered by nbody's phi inputs through non-Assign passthrough instructions (list subscript operations producing CheckVar intermediaries).
1 parent ea68ae2 commit 72cbb07

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Python/jit/hir/refcount_env_c.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ static int phi_use_cmp(const void *a, const void *b) {
6565
return 0;
6666
}
6767

68-
/* ---- modelReg: chase Assign chains ---- */
68+
/* ---- modelReg: chase through passthroughs (matches phx_rc_model_reg) ---- */
69+
70+
extern void *phx_rc_model_reg(void *reg);
6971

7072
static void *model_reg(void *reg) {
71-
return hir_chase_assign(reg);
73+
return phx_rc_model_reg(reg);
7274
}
7375

7476
/* ---- Public API ---- */

0 commit comments

Comments
 (0)