-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: proposed #cgo noescape seems redundant #64857
Comments
@eliasnaur I see a third case, C can return a Go pointer back to go. The escape analysis is able to model this properly when reading go code, but the noescape pragmas are way under capable compared to the level of detail the escape analysis read code. |
Yes, I think (if my memory serves) the issue has to do with |
@eliasnaur For such a Go function:
without And pin is another thing. |
Thank you. I missed that a returned value is a violation of "never passes the Go pointer back to Go code". |
Go version
go1.22rc1
What operating system and processor architecture are you using (
go env
)?What did you do?
The proposed
#cgo noescape
pragma (#56378) is documented to say:However, the property "If the C function does not keep a copy of the Go pointer" seems guaranteed for non-pinned memory by the rule that
So my question is: what can "#cgo noescape" promise that is not already promised?
One answer may be "pinned objects may be retained by C". But then why not force objects passed to runtime.Pinner to the heap?
Another answer may be "Go objects may escape through callbacks to from C to Go", then that seems entirely covered by the "#cgo nocallback" pragma.
In summary, "#cgo noescape" seems to add no useful information.
What did you expect to see?
No "#cgo noescape" pragma, or clearer documentation what "#cgo noescape" promises that is not already promised.
What did you see instead?
A seemingly redundant "#cgo noescape" pragma.
The text was updated successfully, but these errors were encountered: