Fix short-circuiting when TSDInfo not present, preventing reading DTVInfo#1294
Merged
christos68k merged 3 commits intoopen-telemetry:mainfrom Mar 31, 2026
Conversation
- Only error out if BOTH reads fail - Only set the value if not an error on read - Add a regression test that builds an mock ELF file to verify the correct behaviour
dalehamel
commented
Mar 27, 2026
| // buildTestELF creates a minimal 64-bit ELF binary with the given dynamic symbols. | ||
| // Each symbol maps to its corresponding code byte slice. The resulting ELF has a | ||
| // SysV hash table so pfelf.File can resolve symbols via LookupSymbol/SymbolData. | ||
| func buildTestELF(t *testing.T, machine elf.Machine, symbols map[string][]byte) *pfelf.File { |
Contributor
Author
There was a problem hiding this comment.
This is a bit heavy but I wanted to be sure that this regression was caught cleanly. It might be useful elsewhere, but for now i think this is an OK spot for it.
Disclaimer: I had AI help me write this in order to add the test.
florianl
approved these changes
Mar 30, 2026
Co-authored-by: Florian Lehner <florianl@users.noreply.github.com>
christos68k
approved these changes
Mar 31, 2026
| }, nil | ||
| // Return an error only if both extractions failed. | ||
| if tsdErr != nil && dtvErr != nil { | ||
| return nil, fmt.Errorf("TSD: %s; DTV: %s", tsdErr, dtvErr) |
Member
There was a problem hiding this comment.
Nit: Maybe it's better to introduce TSDError and DTVError inside extract{TSD,DTV}Info and then a simple errors.Join here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Updates ExtractLibcInfo to:
Why
In #929, I incorrectly added short circuiting where we would fail to read the DTV.
During the review of #1226, the first actual use of the DTV, @nsavoire correctly pointed this out (thank you!)
I recall that in an earlier version of the branch, I had anticipated this and just logged an error, but then in subsequent refactoring and addressing feedback this must have gotten lost.
To avoid this from happening again, I've added a regression test which actually calls
ExtractLibcInfowith a stub ELF binary for testing purposes to prove that it correctly still reads the DTV in this edge case where the DTV and TSD are in separate binaries, so we can actually merge them.My apologies for the oversight, between reviews and switching tasks I forgot about this edge case.