]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/pprof: fix pcDeck's frame indexing
authorRhys Hiltner <rhys@justin.tv>
Wed, 9 Mar 2022 15:56:04 +0000 (07:56 -0800)
committerMichael Pratt <mpratt@google.com>
Wed, 9 Mar 2022 17:07:49 +0000 (17:07 +0000)
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 <mpratt@google.com>
Trust: Than McIntosh <thanm@google.com>

src/runtime/pprof/proto.go

index 215bd0bf96cb6c3c811fed3c41baa21b6eb971ca..68dac42d200113bc387bf5f5f1198ffbb705379b 100644 (file)
@@ -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]