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.

@jabrailkhalil

Copy link
Copy Markdown
Contributor Author

Yes. I made the bounds explicit in both the public and internal object-tool APIs: symbols include both endpoints, while disassembly includes the start and excludes the end. I also documented those bounds on the implementation and sample-to-symbol classification. No executable code changed in this follow-up. The existing final-byte regression cases and disassembly tests pass on Linux, and gofmt reports no changes.

@jabrailkhalil

Copy link
Copy Markdown
Contributor Author

@aalexand The function-level bounds documentation is included at current head b370d3d0680142ca3bc395c59b7f15ba46a65da0, as described in my preceding reply. This head's CI is waiting for contributor-run approval, not reporting an executed test failure.

Could a maintainer authorize the pending runs when reviewing? The same approval gate currently holds the other three small fixes (#1032, #1033, #1035); their requested test consolidation/screenshots and recorded validation are in their respective PRs. I am consolidating the request here rather than posting four identical reminders. No CI-policy changes or approval bypass are proposed.

@aalexand
aalexand enabled auto-merge (squash) October 3, 2026 20:04
@aalexand
aalexand merged commit ebaad5f into google:main Oct 3, 2026
40 checks passed
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.

Off-by-1 error in Disasm end address

3 participants