aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime1.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2015-10-16 15:26:00 -0700
committerIan Lance Taylor <iant@golang.org>2015-11-10 22:22:10 +0000
commit9dcc58c3d139ee0475fdaca8119812c014ec5ba1 (patch)
treeb4f7dcc9a2e8819203fce7705dcaadce1ae5fc57 /src/runtime/runtime1.go
parent9c8cd83753fd3ebbe81a72469d8c74441123140c (diff)
downloadgo-9dcc58c3d139ee0475fdaca8119812c014ec5ba1.tar.xz
cmd/cgo, runtime: add checks for passing pointers from Go to C
This implements part of the proposal in issue 12416 by adding dynamic checks for passing pointers from Go to C. This code is intended to be on at all times. It does not try to catch every case. It does not implement checks on calling Go functions from C. The new cgo checks may be disabled using GODEBUG=cgocheck=0. Update #12416. Change-Id: I48de130e7e2e83fb99a1e176b2c856be38a4d3c8 Reviewed-on: https://go-review.googlesource.com/16003 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/runtime1.go')
-rw-r--r--src/runtime/runtime1.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/runtime/runtime1.go b/src/runtime/runtime1.go
index f9b11b4de1..9a468443fd 100644
--- a/src/runtime/runtime1.go
+++ b/src/runtime/runtime1.go
@@ -308,6 +308,7 @@ type dbgVar struct {
// already have an initial value.
var debug struct {
allocfreetrace int32
+ cgocheck int32
efence int32
gccheckmark int32
gcpacertrace int32
@@ -326,6 +327,7 @@ var debug struct {
var dbgvars = []dbgVar{
{"allocfreetrace", &debug.allocfreetrace},
+ {"cgocheck", &debug.cgocheck},
{"efence", &debug.efence},
{"gccheckmark", &debug.gccheckmark},
{"gcpacertrace", &debug.gcpacertrace},
@@ -344,6 +346,7 @@ var dbgvars = []dbgVar{
func parsedebugvars() {
// defaults
+ debug.cgocheck = 1
debug.invalidptr = 1
for p := gogetenv("GODEBUG"); p != ""; {