Skip to content

Commit 599d539

Browse files
committed
Revert "cmd/compile: set conversions to unsafe.Pointer as an escaping operation when -asan is enabled"
This reverts commit 5fd0ed7. Reason for revert: <The internal information in commit message is not removed.> Change-Id: Id6845a9c8114ac71c56a1007a4d133a560a37fbc Reviewed-on: https://go-review.googlesource.com/c/go/+/393314 Trust: Fannie Zhang <[email protected]> Reviewed-by: Eric Fang <[email protected]>
1 parent 9956a54 commit 599d539

File tree

6 files changed

+3
-88
lines changed

6 files changed

+3
-88
lines changed

misc/cgo/testsanitizers/asan_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ func TestASAN(t *testing.T) {
4141
{src: "asan4_fail.go", memoryAccessError: "use-after-poison", errorLocation: "asan4_fail.go:13"},
4242
{src: "asan5_fail.go", memoryAccessError: "use-after-poison", errorLocation: "asan5_fail.go:18"},
4343
{src: "asan_useAfterReturn.go"},
44-
{src: "asan_unsafe_fail1.go", memoryAccessError: "use-after-poison", errorLocation: "asan_unsafe_fail1.go:25"},
45-
{src: "asan_unsafe_fail2.go", memoryAccessError: "use-after-poison", errorLocation: "asan_unsafe_fail2.go:25"},
46-
{src: "asan_unsafe_fail3.go", memoryAccessError: "use-after-poison", errorLocation: "asan_unsafe_fail3.go:18"},
4744
}
4845
for _, tc := range cases {
4946
tc := tc

misc/cgo/testsanitizers/testdata/asan_unsafe_fail1.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

misc/cgo/testsanitizers/testdata/asan_unsafe_fail2.go

Lines changed: 0 additions & 28 deletions
This file was deleted.

misc/cgo/testsanitizers/testdata/asan_unsafe_fail3.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/cmd/compile/internal/escape/expr.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ func (e *escape) exprSkipInit(k hole, n ir.Node) {
100100

101101
case ir.OCONV, ir.OCONVNOP:
102102
n := n.(*ir.ConvExpr)
103-
if (ir.ShouldCheckPtr(e.curfn, 2) || ir.ShouldAsanCheckPtr(e.curfn)) && n.Type().IsUnsafePtr() && n.X.Type().IsPtr() {
104-
// When -d=checkptr=2 or -asan is enabled,
105-
// treat conversions to unsafe.Pointer as an
103+
if ir.ShouldCheckPtr(e.curfn, 2) && n.Type().IsUnsafePtr() && n.X.Type().IsPtr() {
104+
// When -d=checkptr=2 is enabled, treat
105+
// conversions to unsafe.Pointer as an
106106
// escaping operation. This allows better
107107
// runtime instrumentation, since we can more
108108
// easily detect object boundaries on the heap

src/cmd/compile/internal/ir/expr.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,12 +1036,6 @@ func ShouldCheckPtr(fn *Func, level int) bool {
10361036
return base.Debug.Checkptr >= level && fn.Pragma&NoCheckPtr == 0
10371037
}
10381038

1039-
// ShouldAsanCheckPtr reports whether pointer checking should be enabled for
1040-
// function fn when -asan is enabled.
1041-
func ShouldAsanCheckPtr(fn *Func) bool {
1042-
return base.Flag.ASan && fn.Pragma&NoCheckPtr == 0
1043-
}
1044-
10451039
// IsReflectHeaderDataField reports whether l is an expression p.Data
10461040
// where p has type reflect.SliceHeader or reflect.StringHeader.
10471041
func IsReflectHeaderDataField(l Node) bool {

0 commit comments

Comments
 (0)