Skip to content

internal/report: include the last byte in disassembly - #1034

Merged
aalexand merged 3 commits into
google:mainfrom
jabrailkhalil:fix/disasm-symbol-end
Oct 3, 2026
Merged

aalexand merged 3 commits into
google:mainfrom
jabrailkhalil:fix/disasm-symbol-end

Conversation

@jabrailkhalil

Copy link
Copy Markdown
Contributor

Sym.End includes the final byte, while ObjTool.Disasm takes an exclusive end. Passing the symbol end directly omitted the final instruction; the sample filter also discarded samples at that address, including all samples for a one-byte symbol.

Convert bounded symbol ends to exclusive disassembly limits and include the endpoint when collecting samples. Preserve the unknown end of the final nm symbol without overflowing. Regression tests cover the last instruction, endpoint samples, one-byte symbols, and the unknown-end sentinel, and verify that the next symbol is excluded.

Fixes #450.

Validation on Linux (Go 1.26.7):

  • go test ./... -count=1
  • go test -race ./internal/report -count=1
  • go vet -all ./...
  • (cd browsertests && go test ./... -count=1)

I also reproduced the issue through the CLI using a real ELF with adjacent NOP; RET and RET functions: the original report showed only the first instruction and 1 of 8 samples; the fix includes the final RET and all 8 samples. The regression suite fails when either endpoint fix is reverted and when the unknown-end guard is removed.

@aalexand

aalexand commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Does this also warrant any function-level documentation updates somewhere? Do we clearly document the inclusivity-exclusivity everywhere we should?

@codecov-commenter

codecov-commenter commented Oct 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.31%. Comparing base (77d3b59) to head (b370d3d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1034      +/-   ##
==========================================
+ Coverage   67.43%   68.31%   +0.87%     
==========================================
  Files          45       45              
  Lines        7868     7871       +3     
==========================================
+ Hits         5306     5377      +71     
+ Misses       2118     2046      -72     
- Partials      444      448       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.