-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/cgo: replace _Cgo_use with runtime.KeepAlive? #20281
Comments
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 |
Thanks, Ian. I think we have (or could easily add) an annotation for making parameters escape. Will dig and experiment. |
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 |
As established above, the answer is "no." Closing. |
Can _Cgo_use and all associated machinery and runtime checks be replaced with calls to runtime.KeepAlive? Seems like it would generate simpler and faster code.
@ianlancetaylor
The text was updated successfully, but these errors were encountered: