Skip to content

fix(ebpf): support Go 1.26 pclntab where pcHeader.textStart is always zero#2

Open
harveywong98 wants to merge 1 commit intocoroot:mainfrom
harveywong98:pr/go126-coroot
Open

fix(ebpf): support Go 1.26 pclntab where pcHeader.textStart is always zero#2
harveywong98 wants to merge 1 commit intocoroot:mainfrom
harveywong98:pr/go126-coroot

Conversation

@harveywong98
Copy link
Copy Markdown

@harveywong98 harveywong98 commented Apr 20, 2026

Problem

Go 1.26 + CGO binaries produce corrupted flame graphs with wrong function names.

Root Cause

  1. Go 1.26 permanently zeroes pcHeader.textStart in pclntab
  2. CGO + external linking places C code before runtime.text, so runtime.text ≠ .text.Addr
  3. The old fallback to .text.Addr shifts all functab PC offsets → corrupted flame graph

Fix

When pcHeader.textStart == 0, look up runtime.text from .symtab before falling back to .text.Addr:

pcHeader.textStart  →  0 on Go 1.26+
findRuntimeTextSymbol() via .symtab
.text.Addr          →  last resort (pure-Go non-PIE only)

Tests

Added go26 and go26-static test binaries (Go 1.26) to TestSelfGoSymbolComparison. Verified in production with a Go 1.26 + CGO service.

References

  1. Go 1.26 zeroes pcHeader.textStart
    golang/go@0e1bd8b
  2. Go 1.26 linker changes
    https://go.dev/doc/go1.26#linker

@harveywong98 harveywong98 marked this pull request as draft April 20, 2026 11:20
… zero

Go 1.26 permanently zeroes the textStart field in pcHeader (.gopclntab),
so ParseRuntimeTextFromPclntab18 now always returns 0.

For pure-Go binaries the old fallback to .text.Addr is correct, but for
CGO + external-link binaries C code is placed before runtime.text in
.text, making .text.Addr wrong and corrupting all functab PC offsets.

Fix: when textStart == 0, look up "runtime.text" from .symtab before
falling back to .text.Addr. Adds findRuntimeTextSymbol() for this lookup.

Also adds Go 1.26 test binaries (go26, go26-static) and corresponding
test cases in TestSelfGoSymbolComparison.

Ref: golang/go@0e1bd8b
Ref: https://go.dev/doc/go1.26
@harveywong98 harveywong98 reopened this Apr 21, 2026
@harveywong98 harveywong98 marked this pull request as ready for review April 21, 2026 11:46
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.

1 participant