internal/report: guard against nil Symbol regexp in disasm and source rendering - #1014
internal/report: guard against nil Symbol regexp in disasm and source rendering#1014anishesg wants to merge 2 commits into
Conversation
… rendering The disasm page crashes when accessed without a filter parameter because the Symbol regexp is nil. The code in PrintAssembly (report.go:400) and printSource (source.go:52) attempted to dereference the nil pointer when calling o.Symbol.String() or o.Symbol.MatchString(). Signed-off-by: anish <anishesg@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1014 +/- ##
=======================================
Coverage 67.35% 67.35%
=======================================
Files 44 44
Lines 7793 7803 +10
=======================================
+ Hits 5249 5256 +7
- Misses 2112 2115 +3
Partials 432 432 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Do you mind attaching before/after screenshots or outputs from the tool to demonstrate the effect of the fix? Also a question on this:
Could you elaborate in the description why different architectures affect this? |
| var address *uint64 | ||
| if hex, err := strconv.ParseUint(o.Symbol.String(), 0, 64); err == nil { | ||
| address = &hex | ||
| if o.Symbol != nil { |
There was a problem hiding this comment.
I don't think o.Symbol is nil in the described scenario, I think it points to a regexp for empty string.
If o.Symbol was nil, o.Symbol.String() would panic.
I don't think this PR fixes anything, so I'll close it.
The disasm page crashes when accessed without a filter parameter because the Symbol regexp is nil. The code in PrintAssembly (report.go:400) and printSource (source.go:52) attempted to dereference the nil pointer when calling o.Symbol.String() or o.Symbol.MatchString().
This fix adds nil checks before accessing the Symbol regexp in three locations: PrintAssembly, printSource, and MakeWebList. When Symbol is nil, the code now treats it as matching all symbols (for MatchString) or uses an empty string in error messages (for String()).
The issue manifests when viewing profiles from different architectures (e.g., darwin/arm64 on linux/amd64) because the web UI calls the disasm endpoint without a symbol filter, causing a nil pointer dereference that displays as "no matches found for regexp:" with an empty regexp value.
Fixes #789