]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: set conversions to unsafe.Pointer as an escaping operation when -asan...
authorfanzha02 <fannie.zhang@arm.com>
Mon, 7 Jun 2021 06:24:45 +0000 (14:24 +0800)
committerFannie Zhang <Fannie.Zhang@arm.com>
Wed, 16 Mar 2022 07:03:20 +0000 (07:03 +0000)
commit5fd0ed7aaf39f783ea6f505a3f2ac7d9da7cb03b
tree203b7f1f8520ba851f5ec949f53efd859c401a50
parentd34287a4f68de5b8a796ec50b8c6b0582a4afc40
cmd/compile: set conversions to unsafe.Pointer as an escaping operation when -asan is enabled

When ASan is enabled, treat conversions to unsafe.Pointer as
an escaping operation. In this way, all pointer operations on
the stack objects will become operations on the escaped heap
objects. As we've already supported ASan detection of error
memory accesses to heap objects. With this trick, we can use
-asan option to report errors on bad stack operations.

Add test cases.

Updates #44853.

CustomizedGitHooks: yes
Change-Id: I4e7fe46a3ce01f0d219e6a67dc50f4aff7d2ad87
Reviewed-on: https://go-review.googlesource.com/c/go/+/325629
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
misc/cgo/testsanitizers/asan_test.go
misc/cgo/testsanitizers/testdata/asan_unsafe_fail1.go [new file with mode: 0644]
misc/cgo/testsanitizers/testdata/asan_unsafe_fail2.go [new file with mode: 0644]
misc/cgo/testsanitizers/testdata/asan_unsafe_fail3.go [new file with mode: 0644]
src/cmd/compile/internal/escape/expr.go
src/cmd/compile/internal/ir/expr.go