You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CRuby's `Exception#backtrace` reports the full live stack at raise time.
monoruby only recorded the frames the exception actually unwound through
(raise site down to the rescuing frame), so a backtrace for an exception
raised and rescued in the same method was missing that frame's callers.
- Add `Executor::complete_backtrace_for_rescue`, called once at the catch
point (`handle_error`'s rescue branch, before `take_ex_obj`). It walks
the still-live caller frames of the rescuing frame via each inner
frame's saved call-site pc (the same mechanism as `Kernel#caller`) and
appends the cheap `(loc, sourceinfo, fid)` tuples. No string formatting
happens here — that stays lazy in `#backtrace`. Control-flow
pseudo-errors (MethodReturn / BlockBreak / Throw) never reach this path,
so they pay nothing, keeping raise cheap.
- Render backtrace frame owners with their fully-qualified name in
`func_description` (`Ns::Cx.foo`, not `Cx.foo`), special-casing Object
so plain top-level methods still read as `Object#foo`.
- Memoize `#backtrace` into the `/backtrace` hidden ivar so repeated calls
return the same mutable Array (`e.backtrace.unshift(x)` is visible next
call; `e.dup.backtrace` is a distinct object). `set_backtrace` writes
the same ivar, unifying the explicit store with the memo.
- Decouple `#backtrace_locations` from the string backtrace via a new
`__raise_backtrace` intrinsic (raise-time capture only), so
`set_backtrace(strings)` on a never-raised exception keeps
`#backtrace_locations` nil, and an Array of Locations sets both.
Fixes core/exception backtrace_spec, backtrace_locations_spec, and
set_backtrace_spec. Adds tests/backtrace.rs (6 differential tests).
Claude-Session: https://claude.ai/code/session_01XpzdoFu46d2ChJpSzeWsNK
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments