Skip to content

Commit f82597d

Browse files
committed
Fix duplicate JIT frames on tail call re-entry
walk_ruby_stack is re-entered via tail calls to process more frames. On re-entry, in_jit was recomputed from record->state.pc which hasn't changed (non-FP path), causing the JIT frame to be pushed again on every tail call. Guard with !jit_detected so the JIT frame is only pushed once on the first entry.
1 parent ff6be62 commit f82597d

File tree

3 files changed

+2
-1
lines changed

3 files changed

+2
-1
lines changed

support/ebpf/ruby_tracer.ebpf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,8 @@ static EBPF_INLINE ErrorCode walk_ruby_stack(
453453

454454
// Detect if the CPU PC is in the JIT region.
455455
bool in_jit = rubyinfo->jit_start > 0 && record->state.pc >= rubyinfo->jit_start &&
456-
record->state.pc < rubyinfo->jit_end;
456+
record->state.pc < rubyinfo->jit_end &&
457+
!record->rubyUnwindState.jit_detected;
457458

458459
if (in_jit) {
459460
record->rubyUnwindState.jit_detected = true;

support/ebpf/tracer.ebpf.amd64

216 Bytes
Binary file not shown.

support/ebpf/tracer.ebpf.arm64

200 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)