]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: fix the issue that the -asan option cannot print where the error occurred
authorfanzha02 <fannie.zhang@arm.com>
Mon, 27 Dec 2021 08:38:48 +0000 (16:38 +0800)
committerFannie Zhang <Fannie.Zhang@arm.com>
Wed, 29 Dec 2021 04:10:07 +0000 (04:10 +0000)
commit91e782106ea465acc6a4c719081cefb690b28533
treedc69bb7edd41acb438b4bb0564467583eb5f806a
parenta78532a4121d26c33ee3ce69b3dda3a608f5a077
runtime: fix the issue that the -asan option cannot print where the error occurred

The current -asan option does not print where the error occurred. The
reason is that the current implementation calls incorrect asan runtime
functions, which do not pass sp and pc where asan runtime functions are
called, and report the stack trace from the native code. But asan runtime
functions are called from cgo on a separated stack, so it cannot dump the
Go stack trace correctly.

The correct asan runtime function we should call is __asan_report_error,
which will pass sp and pc, and report where the error occurred correctly.

This patch fixes this issue.

Add the test cases.

Fixes #50362

Change-Id: I12ee1d46c7ae069ddef3d23f2fe86e112db60045
Reviewed-on: https://go-review.googlesource.com/c/go/+/374395
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
misc/cgo/testsanitizers/asan_test.go
misc/cgo/testsanitizers/cc_test.go
misc/cgo/testsanitizers/testdata/asan1_fail.go
misc/cgo/testsanitizers/testdata/asan2_fail.go
src/runtime/asan.go
src/runtime/asan/asan.go
src/runtime/asan_amd64.s
src/runtime/asan_arm64.s