Skip to content

Strip trailing NUL byte from Go build IDs#4

Merged
gnurizen merged 1 commit intomainfrom
fix/buildid-nul-terminator
Apr 13, 2026
Merged

Strip trailing NUL byte from Go build IDs#4
gnurizen merged 1 commit intomainfrom
fix/buildid-nul-terminator

Conversation

@gnurizen
Copy link
Copy Markdown
Contributor

Summary

  • Go build IDs in ELF notes are stored as C strings with a trailing NUL terminator. readBuildIDFromELF uses the note header's valSize which includes this terminator, so the returned string contains \x00.
  • Consumers passing these build IDs through profile metadata (e.g. pprof Mapping.BuildID) end up with invalid cache paths during symbolization in Parca.
  • Fix: strings.TrimRight the NUL byte at the source in readBuildIDFromELF.

Fixes parca-dev/parca-agent#3152

Test plan

  • TestReadBuildID_GoNoteNulTrimmed — synthetic ELF with Go note containing trailing NUL, verifies it is stripped
  • TestReadBuildID_GNUNoteUnchanged — synthetic ELF with GNU note, verifies hex-encoded build ID is unaffected
  • go test ./... passes

🤖 Generated with Claude Code

Go build IDs in ELF notes are stored as C strings with a trailing NUL
terminator. The note header's valSize includes this terminator, so
readBuildIDFromELF was returning build ID strings containing \x00.
Consumers passing these through profile metadata (e.g. pprof mappings)
end up with invalid cache paths during symbolization.

Fixes parca-dev/parca-agent#3152

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

oomprof improvements

1 participant