Skip to content

Commit

Permalink
Revert "cmd/compile: set conversions to unsafe.Pointer as an escaping…
Browse files Browse the repository at this point in the history
… 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]>
  • Loading branch information
zhangfannie committed Mar 17, 2022
1 parent 9956a54 commit 599d539
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 88 deletions.
3 changes: 0 additions & 3 deletions misc/cgo/testsanitizers/asan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ func TestASAN(t *testing.T) {
{src: "asan4_fail.go", memoryAccessError: "use-after-poison", errorLocation: "asan4_fail.go:13"},
{src: "asan5_fail.go", memoryAccessError: "use-after-poison", errorLocation: "asan5_fail.go:18"},
{src: "asan_useAfterReturn.go"},
{src: "asan_unsafe_fail1.go", memoryAccessError: "use-after-poison", errorLocation: "asan_unsafe_fail1.go:25"},
{src: "asan_unsafe_fail2.go", memoryAccessError: "use-after-poison", errorLocation: "asan_unsafe_fail2.go:25"},
{src: "asan_unsafe_fail3.go", memoryAccessError: "use-after-poison", errorLocation: "asan_unsafe_fail3.go:18"},
}
for _, tc := range cases {
tc := tc
Expand Down
27 changes: 0 additions & 27 deletions misc/cgo/testsanitizers/testdata/asan_unsafe_fail1.go

This file was deleted.

28 changes: 0 additions & 28 deletions misc/cgo/testsanitizers/testdata/asan_unsafe_fail2.go

This file was deleted.

21 changes: 0 additions & 21 deletions misc/cgo/testsanitizers/testdata/asan_unsafe_fail3.go

This file was deleted.

6 changes: 3 additions & 3 deletions src/cmd/compile/internal/escape/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ func (e *escape) exprSkipInit(k hole, n ir.Node) {

case ir.OCONV, ir.OCONVNOP:
n := n.(*ir.ConvExpr)
if (ir.ShouldCheckPtr(e.curfn, 2) || ir.ShouldAsanCheckPtr(e.curfn)) && n.Type().IsUnsafePtr() && n.X.Type().IsPtr() {
// When -d=checkptr=2 or -asan is enabled,
// treat conversions to unsafe.Pointer as an
if ir.ShouldCheckPtr(e.curfn, 2) && n.Type().IsUnsafePtr() && n.X.Type().IsPtr() {
// When -d=checkptr=2 is enabled, treat
// conversions to unsafe.Pointer as an
// escaping operation. This allows better
// runtime instrumentation, since we can more
// easily detect object boundaries on the heap
Expand Down
6 changes: 0 additions & 6 deletions src/cmd/compile/internal/ir/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -1036,12 +1036,6 @@ func ShouldCheckPtr(fn *Func, level int) bool {
return base.Debug.Checkptr >= level && fn.Pragma&NoCheckPtr == 0
}

// ShouldAsanCheckPtr reports whether pointer checking should be enabled for
// function fn when -asan is enabled.
func ShouldAsanCheckPtr(fn *Func) bool {
return base.Flag.ASan && fn.Pragma&NoCheckPtr == 0
}

// IsReflectHeaderDataField reports whether l is an expression p.Data
// where p has type reflect.SliceHeader or reflect.StringHeader.
func IsReflectHeaderDataField(l Node) bool {
Expand Down

0 comments on commit 599d539

Please sign in to comment.