Skip to content

Commit c8bb4af

Browse files
committed
Fix end-of-stack native resume when skip_native_resume is set
When skip_native_resume is true but jit_detected is false (PC not in JIT region at sample time), the end-of-stack check fell through to PROG_UNWIND_NATIVE. The native unwinder could then encounter the JIT anonymous mapping and re-enter the Ruby unwinder, pushing a JIT frame in the wrong stack position. Check skip_native_resume alongside jit_detected at end-of-stack to prevent resuming native unwinding when the flag is set.
1 parent 477d66d commit c8bb4af

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
@@ -519,7 +519,8 @@ static EBPF_INLINE ErrorCode walk_ruby_stack(
519519
// We have processed all frames in the Ruby VM and can stop here.
520520
// If JIT was detected without FP, the PC is still in the JIT region
521521
// and native unwinding would fail, so we stop.
522-
*next_unwinder = record->rubyUnwindState.jit_detected ? PROG_UNWIND_STOP : PROG_UNWIND_NATIVE;
522+
*next_unwinder = (record->rubyUnwindState.jit_detected || rubyinfo->skip_native_resume)
523+
? PROG_UNWIND_STOP : PROG_UNWIND_NATIVE;
523524
goto save_state;
524525
} else {
525526
// If we aren't at the end, advance the stack pointer to continue from the next frame

support/ebpf/tracer.ebpf.amd64

288 Bytes
Binary file not shown.

support/ebpf/tracer.ebpf.arm64

280 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)