]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: don't instrument copy and append in runtime
authorIan Lance Taylor <iant@golang.org>
Wed, 21 Sep 2016 16:44:40 +0000 (09:44 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 22 Sep 2016 23:37:17 +0000 (23:37 +0000)
commit9d8522fdc72ecc8eaa2d318a2cc04abde9beeb42
treee528995a166f8b6ae8140f3fe4d2150e5a1f1085
parent88d2f9112a0a8afd3a29ac1479d4f17847f16803
cmd/compile: don't instrument copy and append in runtime

Instrumenting copy and append for the race detector changes them to call
different functions. In the runtime package the alternate functions are
not marked as nosplit. This caused a crash in the SIGPROF handler when
invoked on a non-Go thread in a program built with the race detector. In
some cases the handler can call copy, the race detector changed that to
a call to a non-nosplit function, the function tried to check the stack
guard, and crashed because it was running on a non-Go thread. The
SIGPROF handler is written carefully to avoid such problems, but hidden
function calls are difficult to avoid.

Fix this by changing the compiler to not instrument copy and append when
compiling the runtime package. Change the runtime package to add
explicit race checks for the only code I could find where copy is used
to write to user data (append is never used).

Change-Id: I11078a66c0aaa459a7d2b827b49f4147922050af
Reviewed-on: https://go-review.googlesource.com/29472
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
src/cmd/compile/internal/gc/walk.go
src/runtime/crash_cgo_test.go
src/runtime/mprof.go
src/runtime/testdata/testprogcgo/raceprof.go [new file with mode: 0644]