aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/symtab.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2021-03-11 12:28:45 -0500
committerDavid Chase <drchase@google.com>2021-03-31 16:58:28 +0000
commita07f9d2f82598d2f5cc0df0e813a6a2309cb96e6 (patch)
tree51273dc984997839add36fbd04ddec4b8ac3a89d /src/runtime/symtab.go
parentf17b659d0a9a43235f67c155b08023124b3fc35b (diff)
downloadgo-a07f9d2f82598d2f5cc0df0e813a6a2309cb96e6.tar.gz
go-a07f9d2f82598d2f5cc0df0e813a6a2309cb96e6.zip
[release-branch.go1.15] runtime: non-strict InlTreeIndex lookup in Frames.Next
When using cgo, some of the frames can be provided by cgoTraceback, a cgo-provided function to generate C tracebacks. Unlike Go tracebacks, cgoTraceback has no particular guarantees that it produces valid tracebacks. If one of the (invalid) frames happens to put the PC in the alignment region at the end of a function (filled with int 3's on amd64), then Frames.Next will find a valid funcInfo for the PC, but pcdatavalue will panic because PCDATA doesn't cover this PC. Tolerate this case by doing a non-strict PCDATA lookup. We'll still show a bogus frame, but at least avoid throwing. For #44971 Fixes #45302 Change-Id: I9eed728470d6f264179a7615bd19845c941db78c Reviewed-on: https://go-review.googlesource.com/c/go/+/301369 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> (cherry picked from commit e4a4161f1f3157550846e1b6bd4fe83aae15778e) Reviewed-on: https://go-review.googlesource.com/c/go/+/305890
Diffstat (limited to 'src/runtime/symtab.go')
-rw-r--r--src/runtime/symtab.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go
index 1e86662adc2..c77d513e744 100644
--- a/src/runtime/symtab.go
+++ b/src/runtime/symtab.go
@@ -102,7 +102,9 @@ func (ci *Frames) Next() (frame Frame, more bool) {
name := funcname(funcInfo)
if inldata := funcdata(funcInfo, _FUNCDATA_InlTree); inldata != nil {
inltree := (*[1 << 20]inlinedCall)(inldata)
- ix := pcdatavalue(funcInfo, _PCDATA_InlTreeIndex, pc, nil)
+ // Non-strict as cgoTraceback may have added bogus PCs
+ // with a valid funcInfo but invalid PCDATA.
+ ix := pcdatavalue1(funcInfo, _PCDATA_InlTreeIndex, pc, nil, false)
if ix >= 0 {
// Note: entry is not modified. It always refers to a real frame, not an inlined one.
f = nil