Skip to content
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

runtime/cgo: document Handle better #45427

Closed
ainar-g opened this issue Apr 7, 2021 · 3 comments
Closed

runtime/cgo: document Handle better #45427

ainar-g opened this issue Apr 7, 2021 · 3 comments
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ainar-g
Copy link
Contributor

ainar-g commented Apr 7, 2021

CL 295369 (issue #37033) added the new type runtime/cgo.Handle. The documentation currently says:

Handle provides a safe representation of Go values to pass between Go and C. The zero value of a handle is not a valid handle, and thus is safe to use as a sentinel in C APIs.

But it doesn't mention what it means by an “unsafe” value. I assume that what it means is a reference to the “Passing pointers” section of the cgo documentation, but the example code that the package currently provides simply passes a [pointer to an] integer between Go and C.

I think that the code should be replaced with something better documented and closer to real-world scenarios, and also that perhaps direct links to the cgo documentation about which values are typically unsafe should be added.

@dmitshur dmitshur added this to the Go1.17 milestone Apr 7, 2021
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 7, 2021
@dmitshur
Copy link
Contributor

dmitshur commented Apr 7, 2021

CC @oakad, @changkun, @ianlancetaylor.

@ianlancetaylor
Copy link
Contributor

@ainar-g Please comment on https://golang.org/cl/308230. Thanks.

@gopherbot
Copy link

Change https://golang.org/cl/308230 mentions this issue: runtime/cgo: clarify Handle documentation

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 7, 2021
@golang golang locked and limited conversation to collaborators Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants