diff options
| author | Cherry Mui <cherryyz@google.com> | 2022-03-23 12:02:36 -0400 |
|---|---|---|
| committer | Cherry Mui <cherryyz@google.com> | 2022-03-23 17:12:00 +0000 |
| commit | dd211cf039d5a3b57d2188751eca49ad816ed395 (patch) | |
| tree | 68e6e009bfc9b31279bd50ec7b69cc1f0db9e7d5 /src/debug | |
| parent | 909a7a32138367abec92434872695fb65aa9b7d1 (diff) | |
| download | go-dd211cf039d5a3b57d2188751eca49ad816ed395.tar.xz | |
debug/gosym: skip non-real functions in LineToPC lookup
The code iterates through the func table to find a function with
a given file and line number. The code panics if it sees a non-
real function (e.g. go.buildid), because its CU offset is -1,
which causes an index-out-of-bounds error. The debug/gosym package
recovers the panic and returns "not found", without looping
through the rest of the entries.
Skip the non-real functions. They cannot be looked up by line
number anyway.
Fixes #51890.
Change-Id: I96f64c17b4a53ffdce047c8244b35a402a0d39ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/395074
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Diffstat (limited to 'src/debug')
| -rw-r--r-- | src/debug/gosym/pclntab.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/debug/gosym/pclntab.go b/src/debug/gosym/pclntab.go index d9ae8b73a9..2ceea3d46f 100644 --- a/src/debug/gosym/pclntab.go +++ b/src/debug/gosym/pclntab.go @@ -627,6 +627,10 @@ func (t *LineTable) go12LineToPC(file string, line int) (pc uint64) { filetab := f.pcfile() linetab := f.pcln() if t.version == ver116 || t.version == ver118 { + if f.cuOffset() == ^uint32(0) { + // skip functions without compilation unit (not real function, or linker generated) + continue + } cutab = t.cutab[f.cuOffset()*4:] } pc := t.findFileLine(entry, filetab, linetab, int32(filenum), int32(line), cutab) |
