Commit 66f78e9d authored by Cuong Manh Le's avatar Cuong Manh Le Committed by Austin Clements

runtime: mark findObject nosplit

findObject takes the pointer argument as uintptr. If the pointer is to
the local stack and calling findObject happens to require the stack to
be reallocated, then spanOf is called for the old pointer.

Marking findObject as nosplit fixes the issue.

Fixes #35068

Change-Id: I029d36f9c23f91812f18f98839edf02e0ba4082e
Reviewed-on: https://go-review.googlesource.com/c/go/+/202798
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarAustin Clements <austin@google.com>
parent 813d8e88
...@@ -385,6 +385,10 @@ func badPointer(s *mspan, p, refBase, refOff uintptr) { ...@@ -385,6 +385,10 @@ func badPointer(s *mspan, p, refBase, refOff uintptr) {
// refBase and refOff optionally give the base address of the object // refBase and refOff optionally give the base address of the object
// in which the pointer p was found and the byte offset at which it // in which the pointer p was found and the byte offset at which it
// was found. These are used for error reporting. // was found. These are used for error reporting.
//
// It is nosplit so it is safe for p to be a pointer to the current goroutine's stack.
// Since p is a uintptr, it would not be adjusted if the stack were to move.
//go:nosplit
func findObject(p, refBase, refOff uintptr) (base uintptr, s *mspan, objIndex uintptr) { func findObject(p, refBase, refOff uintptr) (base uintptr, s *mspan, objIndex uintptr) {
s = spanOf(p) s = spanOf(p)
// If s is nil, the virtual address has never been part of the heap. // If s is nil, the virtual address has never been part of the heap.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment