fix(interpreter/go): check file ID before symbolizing native frames#1324
Conversation
| if !ef.Type().IsInterpType(libpf.Native) { | ||
| return interpreter.ErrMismatchInterpreterType | ||
| } | ||
| if ef.Length() != 2 || host.FileID(ef.Variable(0)) != g.d.fileID { |
There was a problem hiding this comment.
Can we add a comment here to clarify what this check is guarding against? (native frames that do not belong to the Go binary)
Also do we need the ef.Length() != 2 check? Don't all native frames have length 2? Maybe also add a comment to clarify?
There was a problem hiding this comment.
Added a comment as suggested.
I would prefer something like this though
func (d *goData) canSymbolize(ef libpf.EbpfFrame) bool {
if !ef.Type().IsInterpType(libpf.Native) {
return false
}
fid := host.FileID(ef.Variable(0))
return fid == d.fileID
}There was a problem hiding this comment.
Initially I added the length check as a I vaguely remembered a panic at grafana parsing frames, but now I see the panic was due to corrupted pointers, the length were fine, so we can probably trust ebpf programs and remove the len check.
There was a problem hiding this comment.
Added a comment as suggested.
I would prefer something like this though
That's also fine.
I accidentally noticed this weird problem when there is a incorrect go frame in the middle of libc.
From my libc:
Looking at the go symbolizer it looks like it is symbolizing libc files, which does not seem right.
I managed to dump one of requests for qurious.
otlp-cat-request.pb.bin.zst.zip
Found this on revision
7d44c856bf413930cd0a1b76275ffe4a7a19e1bbSeeking for someone to proof read my test and the fix.