Commit 0601978
Fix ref count insertion bug that causes failure on 3.16
Summary:
Jit/hir/refcount_insertion.cpp keeps two pieces of transient state that must agree:
- env.borrowed_regs — the set of live RegStates that are Borrowed with non-empty support, so they can be promoted to Owned (with an Incref) when their support is invalidated.
- each RegState's own kind_.
invalidateBorrowSupport() walks env.borrowed_regs and asserts every entry is still borrowed. Three call sites moved a RegState to Uncounted via RegState::setUncounted() without removing it from env.borrowed_regs, so a later invalidation found a stale, non-borrowed
entry.
The one that actually fired is in processOutput(): for a passthrough instruction whose output type is immortal-only, the shared RegState is marked Uncounted while the model was still registered as borrowed. Compiling re._parser:parse with its inlined callees hits
this.
The change
Added a setUncounted(Env&, RegState&) helper that drops the borrowed_regs registration before changing the kind, and routed all three sites through it. env.borrow_support is intentionally left as-is — it's a union over all borrowed values, so bits can't be cleared for
one value in isolation, and over-approximating there only costs a scan that finds nothing to promote.
Reviewed By: yoney
Differential Revision: D116666441
fbshipit-source-id: 42c6091cb61e0dbe7a06b17a3ca7b28457e973931 parent 7c20e19 commit 0601978
1 file changed
Lines changed: 16 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
519 | 519 | | |
520 | 520 | | |
521 | 521 | | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
522 | 535 | | |
523 | 536 | | |
524 | 537 | | |
| |||
664 | 677 | | |
665 | 678 | | |
666 | 679 | | |
667 | | - | |
| 680 | + | |
668 | 681 | | |
669 | 682 | | |
670 | 683 | | |
| |||
673 | 686 | | |
674 | 687 | | |
675 | 688 | | |
676 | | - | |
| 689 | + | |
677 | 690 | | |
678 | 691 | | |
679 | 692 | | |
| |||
1034 | 1047 | | |
1035 | 1048 | | |
1036 | 1049 | | |
1037 | | - | |
| 1050 | + | |
1038 | 1051 | | |
1039 | 1052 | | |
1040 | 1053 | | |
| |||
0 commit comments