Skip to content

runtime: attribute panic caller lines#1925

Draft
cpunion wants to merge 7 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-fixedbugs-panic-lines
Draft

runtime: attribute panic caller lines#1925
cpunion wants to merge 7 commits into
xgo-dev:mainfrom
cpunion:codex/goroot-fixedbugs-panic-lines

Conversation

@cpunion

@cpunion cpunion commented May 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • build on the caller-frame metadata path from runtime: track caller frames for LLGo metadata #1884 and update caller line attribution immediately before panic-prone SSA operations
  • preserve the caller-frame snapshot captured at panic time so deferred runtime.Caller(2) can report the panic site
  • add LLGo-run test/go coverage for explicit panic, nil field panic, bounds panic CallersFrames, and deferred return caller lines
  • remove verified darwin/arm64 xfails for bug347.go, bug348.go, issue14646.go, issue29504.go, issue4562.go, and issue5856.go

Scope

  • Left issue27201.go xfailed: it depends on runtime.Stack line output, which is covered by the separate lineinfo/runtime.Stack work.
  • Left issue33724.go xfailed: it currently fails because the promoted-method nil access does not panic, which is nil/method semantics rather than caller-line attribution.
  • This branch is stacked on the already-open caller-frame metadata PR runtime: track caller frames for LLGo metadata #1884; the final commit is the panic-line attribution delta.

Tests

  • go test ./test/go -run TestRuntimePanicCallerLineAttribution -count=1 -timeout=10m
  • go test ./test/go -run 'TestRuntime(Caller|Callers|PanicCaller)' -count=1 -timeout=10m
  • go test ./test/goroot -run TestGoRootRunCases -count=1 -timeout=15m -args -goroot /opt/homebrew/Cellar/go@1.24/1.24.11/libexec -dirs fixedbugs -case '^(fixedbugs/(bug347|bug348|issue14646|issue29504|issue4562|issue5856)\\.go)$' -xfail /dev/null -run-timeout 2m -build-timeout 5m
  • go test ./test/goroot -run TestGoRootRunCases -count=1 -timeout=15m -args -goroot /opt/homebrew/Cellar/go@1.24/1.24.11/libexec -dirs fixedbugs -case '^(fixedbugs/(bug347|bug348|issue14646|issue29504|issue4562|issue5856)\\.go)$' -run-timeout 2m -build-timeout 5m
  • go test ./test/goroot -run TestGoRootRunCases -count=1 -timeout=15m -args -goroot /opt/homebrew/Cellar/go@1.24/1.24.11/libexec -dirs fixedbugs -case '^(fixedbugs/(bug347|bug348|issue14646|issue27201|issue29504|issue33724|issue4562|issue5856)\\.go)$' -run-timeout 2m -build-timeout 5m
  • go test ./ssa -count=1 -timeout=15m
  • go test ./cl -count=1 -timeout=15m
  • (cd runtime && go test ./... -count=1 -timeout=15m)
  • git diff --check

@codecov-commenter

codecov-commenter commented May 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.59036% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cl/compile.go 93.75% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@cpunion

cpunion commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator Author

Added focused package-level coverage for the panic caller-line instrumentation paths.

Changes:

  • Added cl tests for caller-frame tracking guards, runtime caller import forms, frame name normalization, and compiled IR insertion of PushCallerFrame / SetCallerLine / PopCallerFrame for panic-line operations.
  • Added an ssa test for the exported RuntimeFunc wrapper used by the compiler instrumentation.

Local verification:

  • go test -timeout 30m -coverprofile=/tmp/pr1925-cl-ssa-current.cover ./cl ./ssa
    • cl: 94.1% statements
    • ssa: 87.9% statements
  • Local patch-coverage estimate for the previously reported source files: 190/195 executable added lines covered (97.4%).
  • go test ./test/go -run TestRuntimePanicCallerLineAttribution -count=1
  • go test ./test/goroot -run TestGoRoot -goroot "$(go env GOROOT)" -dirs=fixedbugs -case="fixedbugs/(bug347|bug348|issue14646|issue29504|issue4562|issue5856)\\.go$" -count=1 -timeout=30m
  • git diff --check

Pushed commit: 5f4113ff2260d056dc9e3bbfe13d00701f91008a.

CI/Codecov are now rerunning on the updated PR head.

@cpunion

cpunion commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator Author

Merged latest xgo-dev/main and fixed the CI build failure from duplicate runtime.Func.FileLine definitions in runtime/internal/lib/runtime/symtab.go.

The single remaining FileLine implementation keeps the panic/caller-line rtdebug.FrameForPC path first, preserves the main-branch clitedebug.Addrinfo file fallback, and removes the duplicate method body. No print/exponent changes were made.

Local verification:

  • go test ./cl ./ssa -run 'Test.*Caller|Test.*Panic|Test.*FileLine|TestDoesNotExist' -count=1
  • go test ./test/go -run TestRuntimePanicCallerLineAttribution -count=1
  • go test ./test/goroot -run TestGoRootRunCases -count=1 -timeout=15m -args -goroot /opt/homebrew/Cellar/go@1.24/1.24.11/libexec -dirs fixedbugs -case '^(fixedbugs/(bug347|bug348|issue14646|issue29504|issue4562|issue5856)\\.go)$' -xfail /dev/null -run-timeout 2m -build-timeout 5m
  • git diff --check

Pushed commit: f203cff2db8f664efd454ad23367bd65667c85e6.

@cpunion cpunion force-pushed the codex/goroot-fixedbugs-panic-lines branch from f203cff to ac1ef9f Compare June 6, 2026 09:08
@cpunion cpunion force-pushed the codex/goroot-fixedbugs-panic-lines branch from ac1ef9f to f499d7f Compare June 10, 2026 11:30
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.

2 participants