mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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
This commit is contained in:
parent
dfaf1f71e6
commit
1b6807bb06
9 changed files with 161 additions and 50 deletions
|
|
@ -827,7 +827,9 @@ runtime·shrinkstack(G *gp)
|
|||
if(used >= oldsize / 4)
|
||||
return; // still using at least 1/4 of the segment.
|
||||
|
||||
if(gp->syscallsp != 0) // TODO: can we handle this case?
|
||||
// We can't copy the stack if we're in a syscall.
|
||||
// The syscall might have pointers into the stack.
|
||||
if(gp->syscallsp != 0)
|
||||
return;
|
||||
|
||||
#ifdef GOOS_windows
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue