Skip to content

Handle Ruby JIT PC with JIT frame type#17

Closed
dalehamel wants to merge 2 commits intomainfrom
jit-rebase
Closed

Handle Ruby JIT PC with JIT frame type#17
dalehamel wants to merge 2 commits intomainfrom
jit-rebase

Conversation

@dalehamel
Copy link
Copy Markdown
Member

What

Detect JIT frames produced by ruby's yjit / zjit to enable the ruby interpreter to still work if jit is in use.

Screenshot 2025-11-06 at 11 10 10 AM

Why

yjit is a substantial improvement to performance, but currently breaks the ruby interpreter as it will never run, since the PC for the interpreter is never called - the whole point of JIT is to avoid the interpreter after all.

How

We use the SynchronizeMappings hook to detect the ruby JIT address range, and if the PC is in this range we will push a dummy frame to indicate that the leaf is some JIT code.

In the future, we can support the linux jit interface to symbolize these, but for now we just push a dummy frame.

Since Ruby's jit works by just running native code replacing the ISEQ of the leaf CME, we can just switch to unwinding the ruby stack once we detect a JIT frame.

However, since we cannot be guaranteed base pointers are available (and even if they are, we don't seem to be able to further unwind correctly with the native unwinder), we can't switch back to native unwinding once we have detected a JIT frame on the stack. This means that if JIT is enabled, we don't get the "interleaved" native and ruby stacks anymore, but we do still get the native frames on the edge of the stack which are probably the most interesting:

Screenshot 2025-11-06 at 11 15 32 AM

@dalehamel dalehamel force-pushed the jit-rebase branch 3 times, most recently from 2381545 to 4e0dc10 Compare January 20, 2026 19:19
@dalehamel
Copy link
Copy Markdown
Member Author

open-telemetry#1102 opened to upstream this

@github-actions
Copy link
Copy Markdown

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Mar 12, 2026
@github-actions
Copy link
Copy Markdown

Closed as inactive. Feel free to reopen if this PR is still being worked on.

@github-actions github-actions bot closed this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant