Repository navigation
Backtraces: record the call chain when an exception is raised - #516
Merged
Merged
Conversation
Uncaught errors printed "nothing on stack": the backtrace was built from Call objects on the retain stack, which the stackless evaluator no longer leaves there, and the frames are unwound before anything prints. An exception now records its trace from the frame chain at the moment it is raised (IoState_error_ and Coroutine rawSignalException): the raising frame, then each frame waiting on a method or block it called, capped at 64 entries. Exception stackTraceLines formats it; Coroutine backTraceString prints it. pass keeps the original trace. The failing message is added from originalCall or caughtMessage when a tail call replaced its frame. Raising costs about 7-10% more (roughly 3 microseconds). Known limit: a tail call reuses its caller's frame, so the caller of a method's last call has no entry. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011WETVfgtbJ5chDp7AeZUe9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uncaught errors printed "nothing on stack" for nearly every error. The backtrace was built from Call objects on the retain stack, which the stackless evaluator no longer leaves there, and the frames are unwound before anything prints.
Now
How
IoState_recordStackTraceOn_walks the frame chain when an exception is raised (fromIoState_error_andCoroutine rawSignalException) and stores a flat list on the exception: the raising frame, then each frame waiting on a method or block it called. Capped at 64 entries.Exception stackTraceLinesformats it and drops the VM's own raising steps and the host's frames (CLI, browser eval).Coroutine backTraceStringprints it.passkeeps the original trace.forwardmethod raising), the failing message comes fromoriginalCall/caughtMessage.Cost: raising an exception is about 7-10% slower (roughly 3µs on ~30µs).
Known limit: a tail call reuses its caller's frame, so the caller of a method's last call has no entry.
Tests: new
BacktraceTest.io(10 cases) and a Node test for the browser build. 274 Io tests pass on the core and component builds, the C suite, 30 Node tests, and 83/83 in-page tests.Also: Guide section on stack traces, an Unreleased release-notes entry, Plan.md updated, site regenerated.
🤖 Generated with Claude Code
https://claude.ai/code/session_011WETVfgtbJ5chDp7AeZUe9