diff --git a/src/runtime/pprof/proto.go b/src/runtime/pprof/proto.go index 5214374bd9..b01f541375 100644 --- a/src/runtime/pprof/proto.go +++ b/src/runtime/pprof/proto.go @@ -404,6 +404,7 @@ func (b *profileBuilder) appendLocsForStack(locs []uint64, stk []uintptr) (newLo b.deck.reset() // The last frame might be truncated. Recover lost inline frames. + origStk := stk stk = runtime_expandFinalInlineFrame(stk) for len(stk) > 0 { @@ -440,6 +441,9 @@ func (b *profileBuilder) appendLocsForStack(locs []uint64, stk []uintptr) (newLo // Even if stk was truncated due to the stack depth // limit, expandFinalInlineFrame above has already // fixed the truncation, ensuring it is long enough. + if len(l.pcs) > len(stk) { + panic(fmt.Sprintf("stack too short to match cached location; stk = %#x, l.pcs = %#x, original stk = %#x", stk, l.pcs, origStk)) + } stk = stk[len(l.pcs):] continue }