]> Cypherpunks repositories - gostls13.git/commit
cgo: adjust return value location to account for stack copies.
authorKeith Randall <khr@golang.org>
Thu, 25 Sep 2014 14:59:01 +0000 (07:59 -0700)
committerKeith Randall <khr@golang.org>
Thu, 25 Sep 2014 14:59:01 +0000 (07:59 -0700)
commit1b6807bb069c528447270c3d6c66c5c7597f388f
treeb88dfe211ed127362e616742a4b957f32e77ee50
parentdfaf1f71e67de2807e07c880060b457d32a66b8b
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 #8771

LGTM=iant, rsc
R=iant, rsc, khr
CC=golang-codereviews
https://golang.org/cl/144130043
misc/cgo/test/callback.go
misc/cgo/test/callback_c.c
misc/cgo/test/cgo_test.go
src/cmd/cgo/out.go
src/runtime/asm_386.s
src/runtime/asm_amd64.s
src/runtime/asm_arm.s
src/runtime/cgo/callbacks.c
src/runtime/stack.c