Skip to content

Commit 66f78e9

Browse files
cuonglmaclements
authored andcommitted
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Austin Clements <[email protected]>
1 parent 813d8e8 commit 66f78e9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/runtime/mbitmap.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ func badPointer(s *mspan, p, refBase, refOff uintptr) {
385385
// refBase and refOff optionally give the base address of the object
386386
// in which the pointer p was found and the byte offset at which it
387387
// was found. These are used for error reporting.
388+
//
389+
// It is nosplit so it is safe for p to be a pointer to the current goroutine's stack.
390+
// Since p is a uintptr, it would not be adjusted if the stack were to move.
391+
//go:nosplit
388392
func findObject(p, refBase, refOff uintptr) (base uintptr, s *mspan, objIndex uintptr) {
389393
s = spanOf(p)
390394
// If s is nil, the virtual address has never been part of the heap.

0 commit comments

Comments
 (0)