Skip to content

jit: keep the adopted terminal's result when a carrier-drain walk aborts - #1130

Merged
youknowone merged 2 commits into
mainfrom
str
Aug 10, 2026
Merged

jit: keep the adopted terminal's result when a carrier-drain walk aborts#1130
youknowone merged 2 commits into
mainfrom
str

Conversation

@youknowone

Copy link
Copy Markdown
Owner

drive_bridge_carrier_walk's abort tail called fbw_finish_payload_reset()
after try_adopt_blackhole, wiping the DoneWithThisFrame* value the adopt had
just stored. The guard's caller (fbw_finish_concrete_take in call_jit.rs)
then found no concrete, and because the adopt had committed the walk-end state
it did not replay through the blackhole either, so the frame's return value
reached Python as None.

pickletools.optimize() has a single return out.getvalue(); under the JIT it
returned None and pickle.loads raised EOFError: Ran out of input
(test.test_pickletools OptimizedPickleTests.test_ints).

Clear the stash before the adopt instead. A stale sub-walk stash is still
discarded, and whatever the adopt installs survives. A declined adopt inherits
the cleared slot, so if !adopted { reset } alone would not be equivalent.
discard_bridge_carrier_walk, the only call between the adopt and the caller's
take, sets no payload.

run_perfn_walk's epilogue already guards this exact hazard
(blackhole_terminal_no_replay, "otherwise a DoneWithThisFrame result is
discarded"), but trace_bytecode returns the carrier drain's action
immediately, so that epilogue never runs on this path. A census of the four
try_adopt_blackhole call sites found this to be the only unguarded one.

Verification

before after
test.test_pickletools FAILED (errors=1) ×3 OK ×3
CPython gate (108 to run, 22 skipped) PASS 106 / FAIL 2 PASS 107 / FAIL 1

The remaining gate failure is test_re, the unrelated pre-existing defect
owned by #1122.

pyre/extra_tests/parity_tests/pickletools_optimize_bridge_abort.py is the
regression guard (0.2 s). A fixed input does not reproduce the defect — the
varying protocol/width matrix and a second round are both required.

🤖 Generated with Claude Code

`drive_bridge_carrier_walk`'s abort tail called `fbw_finish_payload_reset`
after `try_adopt_blackhole`, which had just stored the adopted blackhole
terminal's `DoneWithThisFrame*` value there. The reset is older than the
adopt, which was inserted above it, so the drain cleared the frame's return
value on every adopted abort.

The drop is silent. The adopt also commits the walk-end state, so the caller
finds no concrete to hand back (`fbw_finish_concrete_take`) and does not
replay through the blackhole either; the frame's return value reaches Python
as None.

Clear the stash before the adopt instead. A stale sub-walk value is still
discarded, and whatever the adopt installs now survives to the caller. The
non-adopted leg keeps its post-discard reset, and a CRN adoption stores
nothing, so neither leg can carry a stale value forward.

`test.test_pickletools` `OptimizedPickleTests.test_ints` failed on this:
`pickletools.optimize` returned None and `pickle.loads` raised `EOFError:
Ran out of input`. The CPython suite gate goes from PASS 106/FAIL 2 to
PASS 107/FAIL 1, the remaining failure being the pre-existing `test_re`.
The parity test reproduces the defect in 0.2s.

Assisted-by: Claude
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@youknowone, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 33 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 88987c3a-3fa0-4bf3-909f-dfa295512a50

📥 Commits

Reviewing files that changed from the base of the PR and between 9d46d95 and 6147b27.

📒 Files selected for processing (2)
  • pyre/extra_tests/parity_tests/pickletools_optimize_bridge_abort.py
  • pyre/pyre-jit-trace/src/trace.rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

🤖 Codex parity review

Static analysis of this diff vs the local RPython/PyPy sources (commit 6147b27).
Updated: 2026-08-10T00:33:21.640Z

Files in the reviewed diff
pyre/extra_tests/parity_tests/pickletools_optimize_bridge_abort.py
pyre/pyre-jit-trace/src/trace.rs

1. Regressions to PyPy parity introduced by this patch

None.

2. Other mismatches introduced by this patch

None.

3. Pre-existing mismatches (already present before this patch)

None.

4. Structural adaptations

  • pyre/pyre-jit-trace/src/trace.rs:2061 ↔ rpython/jit/metainterp/blackhole.py:1820 — PyPy propagates the blackhole terminal directly as a JitException; Rust’s bridge-carrier path returns to a caller and therefore uses a rooted finish-result stash. Resetting that stash immediately before adoption is the required Rust-side equivalent: it discards a sub-walk residue while preserving the newly adopted DoneWithThisFrame* result.
  • pyre/extra_tests/parity_tests/pickletools_optimize_bridge_abort.py:21 ↔ no local rpython/pypy counterpart — this is a CPython-stdlib regression fixture for pickletools.optimize, not a port of PyPy/RPython source. It exercises the observable Python 3.11+/CPython-compatible behavior and introduces no runtime semantic divergence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant