Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/cgo: replace _Cgo_use with runtime.KeepAlive? #20281
They aren't the same thing. Given a pointer variable
There may be other ways to fix this problem--using segmented stacks for this specific case comes to mind--but simply using
This seems related to a discussion I had with @aclements last week.
The reason the arguments to cgo calls need to escape is because the Go stack may be resized during the call: if the C function calls back into Go, that call will resume on the same Go stack and might exhaust it. If we instead use a new Go stack for each call from C, we could exclude that possibility and treat every C function as implicitly