Skip to content

runtime: start FP walks from a live caller frame#2151

Open
cpunion wants to merge 1 commit into
xgo-dev:mainfrom
cpunion:codex/panic-fp-caller-frame
Open

runtime: start FP walks from a live caller frame#2151
cpunion wants to merge 1 commit into
xgo-dev:mainfrom
cpunion:codex/panic-fp-caller-frame

Conversation

@cpunion

@cpunion cpunion commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Fixes #2149.

Problem

A shallow unrecovered panic built with -O0 -ldflags=-w=false can fall back to the raw clite address dump instead of LLGo's Go-style traceback. It was first noticed when a logging dependency graph and panic were combined in one probe, but the minimized trigger does not depend on log.

Without this PR, output can look like:

panic: shallow-panic

[0x... command-line-arguments.panicSite+0x20, SP = ...]
[0x... command-line-arguments.main+..., SP = ...]

Root cause

llgo_framepointer returned the C helper's own __builtin_frame_address(0). The Go walker dereferenced that stack address after the helper returned, so optimized layouts only worked while stale frame bytes happened to remain intact. In the failing O0/DWARF layout, the saved-FP slot was already overwritten and the walk stopped before collecting a frame.

Change

  • Read and return the saved caller FP while the C helper frame is still alive.
  • Remove the Go walker's old one-frame skip compensation so existing Caller/Callers depths remain unchanged.
  • Cover a shallow panic under O0/O2 with DWARF both enabled and disabled.

This is independent of #2115: that issue owns precise PCLN statement sites. It also does not rely on #2143; optimization can hide the stale-frame bug but is not the correctness fix.

Verification

macOS arm64, Go 1.26.5 / LLVM 19:

  • go test -vet=off ./... -count=1 -timeout=20m
  • cd runtime && go test -vet=off ./... -count=1 -timeout=15m
  • caller/logging/panic/introspection/Stack/line-info acceptance tests
  • O0/O2 x DWARF on/off shallow-panic matrix

Ubuntu amd64, Go 1.26.5 / LLVM 19.1.7, offline container limited to 2 CPUs, 15 GiB memory, and 512 PIDs:

  • O0/O2 x DWARF on/off shallow-panic matrix

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cpunion
cpunion marked this pull request as ready for review July 22, 2026 08:16
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runtime: panic FP walk can start from a returned C helper frame

1 participant