-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
What version of Go are you using (go version
)?
$ go version go version devel go1.18-b357b05b70 Thu Dec 23 20:03:38 2021 +0000 linux/arm64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="arm64" GOBIN="" GOCACHE="/home/fanzha02/.cache/go-build" GOENV="/home/fanzha02/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/fanzha02/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/fanzha02/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/home/fanzha02/work/go_project/govscode/gomain" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/fanzha02/work/go_project/govscode/gomain/pkg/tool/linux_arm64" GOVCS="" GOVERSION="devel go1.18-b357b05b70 Thu Dec 23 20:03:38 2021 +0000" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/fanzha02/work/go_project/govscode/gomain/src/go.mod" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1769828368=/tmp/go-build -gno-record-gcc-switches"
What did you do?
- go build -asan test.go (https://go.dev/play/p/ufagb_TwZfi)
- ./test
// test.go
package main
import (
"fmt"
"unsafe"
)
func main() {
p := new([1024*100]int)
p[1] = 10
r := bar(&p[102399]) // line0
fmt.Printf("r value is %d", r)
}
func bar(a *int) int {
p := (*int)(unsafe.Add(unsafe.Pointer(a), 2*unsafe.Sizeof(int(1))))
*p = 10 // BO0M // line1
return *p
}
What did you expect to see?
I expect the -asan can print where the error occurred, like
#0 0x454ad0 in main.bar test.go:line1
#1 0x454ad0 in main.main test.go:line0
What did you see instead?
The -asan option does not print where the error occurred.
==5406==ERROR: AddressSanitizer: use-after-poison on address 0x204000348008 at pc 0x0000004916a8 bp 0xffffd62ddc90 sp 0xffffd62ddcb0
WRITE of size 8 at 0x204000348008 thread T0
#0 0x4916a4 in __asan_write_go /home/fanzha02/work/go_project/govscode/gomain/src/runtime/asan/asan.go:46
#1 0x458d6c in asancall /home/fanzha02/work/go_project/govscode/gomain/src/runtime/asan_arm64.s:60
Address 0x204000348008 is a wild pointer.
SUMMARY: AddressSanitizer: use-after-poison /home/fanzha02/work/go_project/govscode/gomain/src/runtime/asan/asan.go:46 in __asan_write_go
Shadow bytes around the buggy address:
0x041800068fb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x041800068fc0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x041800068fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x041800068fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x041800068ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x041800069000: f7[f7]f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
0x041800069010: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
0x041800069020: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
0x041800069030: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
0x041800069040: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7
0x041800069050: f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7 f7