Skip to content

Commit c39abe0

Browse files
qmuntalgopherbot
authored andcommitted
runtime: fix TestSehUnwind
The various TestSehUnwind tests recently started to fail due an unrelated refactor (in CL 698098) that made the stack frames to not match the expected pattern. This CL updates the tests to be more robust to such changes. Fixes #75467 Change-Id: I7950332bb6ca54e4bf693d13e2490b3d9d901dde Reviewed-on: https://go-review.googlesource.com/c/go/+/703779 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Auto-Submit: Quim Muntal <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent e3ed0fb commit c39abe0

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/runtime/runtime-seh_windows_test.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,20 @@ func TestSehLookupFunctionEntry(t *testing.T) {
6565
}
6666
}
6767

68-
func sehCallers() []uintptr {
69-
// We don't need a real context,
70-
// RtlVirtualUnwind just needs a context with
71-
// valid a pc, sp and fp (aka bp).
68+
//go:noinline
69+
func newCtx() *windows.Context {
7270
var ctx windows.Context
7371
ctx.SetPC(sys.GetCallerPC())
7472
ctx.SetSP(sys.GetCallerSP())
7573
ctx.SetFP(runtime.GetCallerFp())
74+
return &ctx
75+
}
76+
77+
func sehCallers() []uintptr {
78+
// We don't need a real context,
79+
// RtlVirtualUnwind just needs a context with
80+
// valid a pc, sp and fp (aka bp).
81+
ctx := newCtx()
7682

7783
pcs := make([]uintptr, 15)
7884
var base, frame uintptr
@@ -84,7 +90,7 @@ func sehCallers() []uintptr {
8490
}
8591
pcs[i] = ctx.PC()
8692
n++
87-
windows.RtlVirtualUnwind(0, base, ctx.PC(), fn, unsafe.Pointer(&ctx), nil, &frame, nil)
93+
windows.RtlVirtualUnwind(0, base, ctx.PC(), fn, unsafe.Pointer(ctx), nil, &frame, nil)
8894
}
8995
return pcs[:n]
9096
}
@@ -120,6 +126,9 @@ func testSehCallersEqual(t *testing.T, pcs []uintptr, want []string) {
120126
// These functions are skipped as they appear inconsistently depending
121127
// whether inlining is on or off.
122128
continue
129+
case "runtime_test.sehCallers":
130+
// This is an artifact of the implementation of sehCallers.
131+
continue
123132
}
124133
got = append(got, name)
125134
}

0 commit comments

Comments
 (0)