From 6dca1a29ab57576807d84485ff7d908d68e5c008 Mon Sep 17 00:00:00 2001 From: Felix Geisendörfer Date: Wed, 26 Apr 2023 10:07:02 +0200 Subject: runtime: add test for systemstack frame pointer adjustment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add TestSystemstackFramePointerAdjust as a regression test for CL 489015. By turning stackPoisonCopy into a var instead of const and introducing the ShrinkStackAndVerifyFramePointers() helper function, we are able to trigger the exact combination of events that can crash traceEvent() if systemstack restores a frame pointer that is pointing into the old stack. Updates #59692 Change-Id: I60fc6940638077e3b60a81d923b5f5b4f6d8a44c Reviewed-on: https://go-review.googlesource.com/c/go/+/489115 TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui Reviewed-by: Michael Knyszek Run-TryBot: Felix Geisendörfer --- src/runtime/stack.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/runtime/stack.go') diff --git a/src/runtime/stack.go b/src/runtime/stack.go index 54513eba65..01d6b9c22f 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -108,13 +108,16 @@ const ( stackDebug = 0 stackFromSystem = 0 // allocate stacks from system memory instead of the heap stackFaultOnFree = 0 // old stacks are mapped noaccess to detect use after free - stackPoisonCopy = 0 // fill stack that should not be accessed with garbage, to detect bad dereferences during copy stackNoCache = 0 // disable per-P small stack caches // check the BP links during traceback. debugCheckBP = false ) +var ( + stackPoisonCopy = 0 // fill stack that should not be accessed with garbage, to detect bad dereferences during copy +) + const ( uintptrMask = 1<<(8*goarch.PtrSize) - 1 -- cgit v1.3