diff options
| author | qmuntal <quimmuntal@gmail.com> | 2025-09-15 16:02:22 +0200 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-09-15 17:36:12 -0700 |
| commit | c39abe065886f62791f41240eef6ca03d452a17b (patch) | |
| tree | 0cee75a87f1ea77b3832cfd6e36f8fb1e3dee710 /src | |
| parent | e3ed0fbe6a4c7c5e91a4a82c1bcbc96b9ac37016 (diff) | |
| download | go-c39abe065886f62791f41240eef6ca03d452a17b.tar.xz | |
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/runtime/runtime-seh_windows_test.go | 19 |
1 files changed, 14 insertions, 5 deletions
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) } |
