Skip to content

Commit eaa952b

Browse files
committed
YJIT: Print Rc strong and weak count on assert failure
For <https://bugs.ruby-lang.org/issues/21716>, the panic is looking like some sort of third party memory corruption, with YJIT taking the fall. At the point of this assert, the assembler has dropped, so there's nothing in YJIT's code other than JITState that could be holding on to these transient `PendingBranchRef`. The strong count being more than a handful or the weak count is non-zero shows that someone in the process (likely some native extension) corrupted the Rc's counts.
1 parent f3d1557 commit eaa952b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

yjit/src/core.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2419,7 +2419,9 @@ impl<'a> JITState<'a> {
24192419
// Pending branches => actual branches
24202420
outgoing: MutableBranchList(Cell::new(self.pending_outgoing.into_iter().map(|pending_out| {
24212421
let pending_out = Rc::try_unwrap(pending_out)
2422-
.ok().expect("all PendingBranchRefs should be unique when ready to construct a Block");
2422+
.unwrap_or_else(|rc| panic!(
2423+
"PendingBranchRef should be unique when ready to construct a Block. \
2424+
strong={} weak={}", Rc::strong_count(&rc), Rc::weak_count(&rc)));
24232425
pending_out.into_branch(NonNull::new(blockref as *mut Block).expect("no null from Box"))
24242426
}).collect()))
24252427
});

0 commit comments

Comments
 (0)