]> Cypherpunks repositories - gostls13.git/commit
runtime: add optional expensive check for invalid cgo pointer passing
authorIan Lance Taylor <iant@golang.org>
Sat, 14 Nov 2015 01:45:22 +0000 (17:45 -0800)
committerIan Lance Taylor <iant@golang.org>
Mon, 16 Nov 2015 18:39:06 +0000 (18:39 +0000)
commitbe1ef467756bff3c475321a2213182020454075e
tree5b6258c4337051caac514ac9179528e547eede20
parent1860a0fa571ff13ed2c4a23d50d55945720c86bb
runtime: add optional expensive check for invalid cgo pointer passing

If you set GODEBUG=cgocheck=2 the runtime package will use the write
barrier to detect cases where a Go program writes a Go pointer into
non-Go memory.  In conjunction with the existing cgo checks, and the
not-yet-implemented cgo check for exported functions, this should
reliably detect all cases (that do not import the unsafe package) in
which a Go pointer is incorrectly shared with C code.  This check is
optional because it turns on the write barrier at all times, which is
known to be expensive.

Update #12416.

Change-Id: I549d8b2956daa76eac853928e9280e615d6365f4
Reviewed-on: https://go-review.googlesource.com/16899
Reviewed-by: Russ Cox <rsc@golang.org>
13 files changed:
misc/cgo/errors/ptr.go
src/cmd/compile/internal/gc/builtin.go
src/cmd/compile/internal/gc/builtin/runtime.go
src/cmd/compile/internal/gc/cgen.go
src/runtime/cgocall.go
src/runtime/cgocheck.go [new file with mode: 0644]
src/runtime/extern.go
src/runtime/mbarrier.go
src/runtime/mbitmap.go
src/runtime/mgc.go
src/runtime/mgcmark.go
src/runtime/runtime1.go
src/runtime/slice.go