stack-trace

command
v1.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

stack-trace demonstrates the VM stack trace captured when a runtime error escapes to the embedder, with emphasis on the sub-context spanning added in CaptureStackTrace (the "<foreign-call boundary>" frame).

A trace is built by walking the continuation chain. Two things make the output worth studying:

  1. Tail calls leave no frame. Wile is properly tail-recursive, so a chain of tail calls collapses to a single frame. To see depth you need non-tail calls — here each call is wrapped in (+ 1 _) so the caller's frame must survive to receive the return value.

  2. Go primitives that call back into Scheme (a parameter converter, eval, an exception thunk) run that Scheme in a *sub-context*. The walk hops the Go boundary via parentMC and inserts a synthetic "<foreign-call boundary>" frame at the crossing, so the outer Scheme frames that led into the Go primitive are not lost.

Both programs below are wrapped in a single (begin ...) so they parse as one expression: that keeps every define and the call site live on one continuation chain. (EvalMultiple* compiles each top-level form independently, which would drop the very parent frames this example is about.)

Run with: go run ./examples/embedding/stack-trace/main.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL