Skip to content

Commit 5b0f859

Browse files
nsrip-ddprattmic
authored andcommitted
runtime/pprof: make TestBlockMutexProfileInlineExpansion stricter
While working on CL 611241 and CL 616375, I introduced a bug that wasn't caught by any test. CL 611241 added more inline expansion at sample time for block/mutex profile stacks collected via frame pointer unwinding. CL 616375 then changed how inline expansion for those stacks is done at reporting time. So some frames passed through multiple rounds of inline expansion, and this lead to duplicate stack frames in some cases. The stacks from TestBlockMutexProfileInlineExpansion looked like sync.(*Mutex).Unlock runtime/pprof.inlineF runtime/pprof.inlineE runtime/pprof.inlineD runtime/pprof.inlineD runtime.goexit after those two CLs, and in particular after CL 616375. Note the extra inlineD frame. The test didn't catch that since it was only looking for a few frames in the stacks rather than checking the entire stacks. This CL makes that test stricter by checking the entire expected stacks rather than just a portion of the stacks. Change-Id: I0acc739d826586e9a63a081bb98ef512d72cdc9a Reviewed-on: https://go-review.googlesource.com/c/go/+/617235 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
1 parent 268eaf9 commit 5b0f859

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/runtime/pprof/pprof_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2727,38 +2727,38 @@ func TestBlockMutexProfileInlineExpansion(t *testing.T) {
27272727
wg.Wait()
27282728

27292729
tcs := []struct {
2730-
Name string
2731-
Collect func([]runtime.BlockProfileRecord) (int, bool)
2732-
SubStack string
2730+
Name string
2731+
Collect func([]runtime.BlockProfileRecord) (int, bool)
2732+
Stack string
27332733
}{
27342734
{
27352735
Name: "mutex",
27362736
Collect: runtime.MutexProfile,
2737-
SubStack: `sync.(*Mutex).Unlock
2737+
Stack: `sync.(*Mutex).Unlock
27382738
runtime/pprof.inlineF
27392739
runtime/pprof.inlineE
2740-
runtime/pprof.inlineD`,
2740+
runtime/pprof.inlineD
2741+
runtime.goexit`,
27412742
},
27422743
{
27432744
Name: "block",
27442745
Collect: runtime.BlockProfile,
2745-
SubStack: `sync.(*Mutex).Lock
2746+
Stack: `sync.(*Mutex).Lock
27462747
runtime/pprof.inlineC
27472748
runtime/pprof.inlineB
2748-
runtime/pprof.inlineA`,
2749+
runtime/pprof.inlineA
2750+
runtime.goexit`,
27492751
},
27502752
}
27512753

27522754
for _, tc := range tcs {
27532755
t.Run(tc.Name, func(t *testing.T) {
27542756
stacks := getProfileStacks(tc.Collect, false)
2755-
for _, s := range stacks {
2756-
if strings.Contains(s, tc.SubStack) {
2757-
return
2758-
}
2757+
if slices.Contains(stacks, tc.Stack) {
2758+
return
27592759
}
27602760
t.Error("did not see expected stack")
2761-
t.Logf("wanted:\n%s", tc.SubStack)
2761+
t.Logf("wanted:\n%s", tc.Stack)
27622762
t.Logf("got: %s", stacks)
27632763
})
27642764
}

0 commit comments

Comments
 (0)