Commit 66850a4
committed
W22 root-cause fix: populate refcount in-state from liveness for n_in==0 blocks
GDB investigation 2026-04-23 17:46Z (per Alex 17:45:31Z 'use gdb to find
the problem' directive) found the await SIGSEGV root cause at
phx_rs_add_copy(rs=NULL) in refcount_pass_c.c:716 (phx_rc_process_output
passthrough branch). The same root cause produces the W22 yield-from
crash class (SIGABRT 134 'register not live' from deopt.cpp:478).
Root cause: phx_rc_use_simple_in_state's n_in==0 branch (legacy from the
CinderX C++ refcount_insertion pass — see git show 1d2b9a7^:Python/
jit/hir/refcount_insertion.cpp:667-672) created an empty PhxStateMap
in_state for blocks with no CFG predecessors. Generator-resume blocks
(yield-from, await, plain generator entry post-RETURN_GENERATOR) all
have in_edges_count() == 0 because the runtime resume edge is not
modelled in the CFG. The empty in-state left env->live_regs empty;
subsequent passthrough output processing called phx_sm_get(&env->
live_regs, model_out) which returned NULL and crashed at
phx_rs_add_copy(NULL, ...).
The bug was inherited from the C++ refcount_insertion.cpp baseline (R3b
port preserved the empty-StateMap behavior verbatim) and was hidden
until W32 (4a01bfa) repaired the gate's --wiring step and exposed
compiled-code execution of yield-from + await patterns. W22 (d25b2f3
through 4a63c4d) narrowly worked around the yield-from trigger via
a pattern-deopt in checkTranslate; this commit fixes the root cause and
removes the deopt.
Fix: populate the n_in==0 in-state from liveness analysis using the
same hir_liveness_foreach_live_in + RegCollector pattern that
phx_rc_initialize_in_state uses for multi-predecessor blocks
(refcount_pass_c.c:447-462). For each live-in reg, add to in_state with
PHX_REF_OWNED kind unless the register's static type is uncounted
(matches the regular phx_rc_process_output ownership-default logic at
line 723-734).
Verification (./python rebuilt with libjit.a relink):
/tmp/repro_min3.py (yield-from auto-compile 1100-iter): PASS EXIT=0,
is_jit_compiled gen_yieldfrom=True (no deopt fallback needed)
/tmp/test_await_autocompile.py: PROGRESSES past the W22 SIGSEGV class
(phx_rs_add_copy NULL fixed) but exposes a SEPARATE deopt-side
issue (deopt.cpp:478 'register v27 not live') at the YieldFrom HIR
instruction's FrameState. Investigation continues.
builder.cpp restored to pre-W22 state: the pattern-deopt for YIELD_VALUE+
RESUME-oparg-2 is removed; YIELD_FROM stays in isSupportedOpcode (it is
a stub in 3.12 per Python/jit_common/opcode_stubs.h, so the case is
dead but harmless).
Per Alex 17:45:31Z + supervisor 17:45:52Z: no more bypass framing,
investigate via gdb, fix the root cause.1 parent 4a63c4d commit 66850a4
2 files changed
Lines changed: 51 additions & 46 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4899 | 4899 | | |
4900 | 4900 | | |
4901 | 4901 | | |
4902 | | - | |
4903 | | - | |
| 4902 | + | |
4904 | 4903 | | |
4905 | 4904 | | |
4906 | 4905 | | |
| |||
4928 | 4927 | | |
4929 | 4928 | | |
4930 | 4929 | | |
4931 | | - | |
4932 | | - | |
4933 | | - | |
4934 | | - | |
4935 | | - | |
4936 | | - | |
4937 | | - | |
4938 | | - | |
4939 | | - | |
4940 | | - | |
4941 | | - | |
4942 | | - | |
4943 | | - | |
4944 | | - | |
4945 | | - | |
4946 | | - | |
4947 | | - | |
4948 | | - | |
4949 | | - | |
4950 | | - | |
4951 | | - | |
4952 | | - | |
4953 | | - | |
4954 | | - | |
4955 | | - | |
4956 | | - | |
4957 | | - | |
4958 | | - | |
4959 | | - | |
4960 | | - | |
4961 | | - | |
4962 | | - | |
4963 | | - | |
4964 | | - | |
4965 | | - | |
4966 | | - | |
4967 | | - | |
4968 | | - | |
4969 | | - | |
4970 | | - | |
4971 | 4930 | | |
4972 | 4931 | | |
4973 | 4932 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
503 | 549 | | |
504 | 550 | | |
505 | 551 | | |
| |||
0 commit comments