mirror of
https://github.com/golang/go
synced 2024-11-08 19:26:14 -07:00
2c58bb2e42
The asan runtime functions may run on stacks that cannot grow, and they do not have large local variables, so it is safe to mark them as NOSPLIT. Add test case. Fixes #50391 Change-Id: Iadcbf1ae0c837d9b64da5be208c7f424e6ba11de Reviewed-on: https://go-review.googlesource.com/c/go/+/374398 Trust: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Fannie Zhang <Fannie.Zhang@arm.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
22 lines
328 B
Go
22 lines
328 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime"
|
|
"unsafe"
|
|
)
|
|
|
|
func main() {
|
|
p := new([1024 * 1000]int)
|
|
p[0] = 10
|
|
r := bar(&p[1024*1000-1])
|
|
fmt.Printf("r value is %d", r)
|
|
}
|
|
|
|
func bar(a *int) int {
|
|
p := unsafe.Add(unsafe.Pointer(a), 2*unsafe.Sizeof(int(1)))
|
|
runtime.ASanWrite(p, 8) // BOOM
|
|
*((*int)(p)) = 10
|
|
return *((*int)(p))
|
|
}
|