summaryrefslogtreecommitdiff
path: root/src/runtime/cgo
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-09-25 07:59:01 -0700
committerKeith Randall <khr@golang.org>2014-09-25 07:59:01 -0700
commit0c34008d4e1b07c77820b855e95971ca0e2d9a8b (patch)
tree312a3e1102bf3e1b30dadcc1c9a1676377c9189f /src/runtime/cgo
parent29ea6456c72c8b6b7f1b5902441ea8ff4c50e65a (diff)
downloadgo-0c34008d4e1b07c77820b855e95971ca0e2d9a8b.tar.gz
cgo: adjust return value location to account for stack copies.
During a cgo call, the stack can be copied. This copy invalidates the pointer that cgo has into the return value area. To fix this problem, pass the address of the location containing the stack top value (which is in the G struct). For cgo functions which return values, read the stktop before and after the cgo call to compute the adjustment necessary to write the return value. Fixes issue 8771 LGTM=iant, rsc R=iant, rsc, khr CC=golang-codereviews https://codereview.appspot.com/144130043
Diffstat (limited to 'src/runtime/cgo')
-rw-r--r--src/runtime/cgo/callbacks.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/runtime/cgo/callbacks.c b/src/runtime/cgo/callbacks.c
index 16614d03d..cea9b1667 100644
--- a/src/runtime/cgo/callbacks.c
+++ b/src/runtime/cgo/callbacks.c
@@ -78,3 +78,6 @@ void (*_cgo_free)(void*) = x_cgo_free;
#pragma cgo_import_static x_cgo_thread_start
extern void x_cgo_thread_start(void*);
void (*_cgo_thread_start)(void*) = x_cgo_thread_start;
+
+#pragma cgo_export_static cgo_topofstack
+#pragma cgo_export_dynamic cgo_topofstack