From: Rhys Hiltner Date: Wed, 9 Mar 2022 15:56:04 +0000 (-0800) Subject: runtime/pprof: fix pcDeck's frame indexing X-Git-Tag: go1.19beta1~1113 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0d33a9967540fe06f5ce7b14790e9be8da576936;p=gostls13.git runtime/pprof: fix pcDeck's frame indexing When building the inlining deck, correctly identify which is the last frame in the deck. Otherwise, when some forms of inlining cause a PC to expand to multiple frames, the length of the deck's two slices will diverge. Fixes #51567 Change-Id: I24e7ba32cb16b167f4307178b3f03c29e5362c4b Reviewed-on: https://go-review.googlesource.com/c/go/+/391134 Reviewed-by: Michael Pratt Trust: Than McIntosh --- diff --git a/src/runtime/pprof/proto.go b/src/runtime/pprof/proto.go index 215bd0bf96..68dac42d20 100644 --- a/src/runtime/pprof/proto.go +++ b/src/runtime/pprof/proto.go @@ -530,7 +530,7 @@ func (d *pcDeck) reset() { // since the stack trace is already fully expanded) and the symbolizeResult // to the deck. If it fails the caller needs to flush the deck and retry. func (d *pcDeck) tryAdd(pc uintptr, frames []runtime.Frame, symbolizeResult symbolizeFlag) (success bool) { - if existing := len(d.pcs); existing > 0 { + if existing := len(d.frames); existing > 0 { // 'd.frames' are all expanded from one 'pc' and represent all // inlined functions so we check only the last one. newFrame := frames[0]