-
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: a type alias of unsafe.Pointer is not treated as unsafe.Pointer #67333
Comments
This seems to me a cgo does not recorgnize that |
I don't know how to fix this except to do full type checking on the cgo input file, which is difficult as we currently expect the type checker to run on cgo output, not cgo input. Fixing this correctly may require something like #16623, which is a lot of work. |
@ianlancetaylor We could probably record type alias only, something like |
We can handle simple cases, but what if we import some other package that has |
A related previous issue was #57926, in which users exploited the desugaring of cgo to declare methods on types that appear to belong to package C: |
@ianlancetaylor Assigned it to you for now, please feel free to update. |
Thanks, I'm unassigning as I have no plans to work on this. |
Go version
go version devel go1.23-07fc59199b Sun May 12 05:36:29 2024 +0000 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Run the following code:
What did you see happen?
The first and third calls panic with
runtime error: cgo argument has Go pointer to unpinned Go pointer
. The second call doesn't panic.What did you expect to see?
Only the first call to panic.
Arguably one might also expect all 3 calls to panic, since this also panics, regardless of the use of an alias:
Which makes the use of the 2nd form rather brittle.
The text was updated successfully, but these errors were encountered: