From: qmuntal Date: Mon, 15 Sep 2025 14:02:22 +0000 (+0200) Subject: runtime: fix TestSehUnwind X-Git-Tag: go1.26rc1~862 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c39abe0658;p=gostls13.git 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 Reviewed-by: Michael Knyszek Auto-Submit: Quim Muntal Reviewed-by: Cherry Mui --- diff --git a/src/runtime/runtime-seh_windows_test.go b/src/runtime/runtime-seh_windows_test.go index 8503a0550c..e1cd0601bb 100644 --- a/src/runtime/runtime-seh_windows_test.go +++ b/src/runtime/runtime-seh_windows_test.go @@ -65,14 +65,20 @@ func TestSehLookupFunctionEntry(t *testing.T) { } } -func sehCallers() []uintptr { - // We don't need a real context, - // RtlVirtualUnwind just needs a context with - // valid a pc, sp and fp (aka bp). +//go:noinline +func newCtx() *windows.Context { var ctx windows.Context ctx.SetPC(sys.GetCallerPC()) ctx.SetSP(sys.GetCallerSP()) ctx.SetFP(runtime.GetCallerFp()) + return &ctx +} + +func sehCallers() []uintptr { + // We don't need a real context, + // RtlVirtualUnwind just needs a context with + // valid a pc, sp and fp (aka bp). + ctx := newCtx() pcs := make([]uintptr, 15) var base, frame uintptr @@ -84,7 +90,7 @@ func sehCallers() []uintptr { } pcs[i] = ctx.PC() n++ - windows.RtlVirtualUnwind(0, base, ctx.PC(), fn, unsafe.Pointer(&ctx), nil, &frame, nil) + windows.RtlVirtualUnwind(0, base, ctx.PC(), fn, unsafe.Pointer(ctx), nil, &frame, nil) } return pcs[:n] } @@ -120,6 +126,9 @@ func testSehCallersEqual(t *testing.T, pcs []uintptr, want []string) { // These functions are skipped as they appear inconsistently depending // whether inlining is on or off. continue + case "runtime_test.sehCallers": + // This is an artifact of the implementation of sehCallers. + continue } got = append(got, name) }