-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid cgoCheckPointer. ref golang/go#12416
- Loading branch information
Showing
1 changed file
with
16 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e969434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach is unsafe. You are passing a pointer to C as a uintptr, where that pointer contains other Go pointers. That breaks the Go 1.6 pointer passing rules (http://tip.golang.org/cmd/cgo/#hdr-Passing_pointers) and also breaks the new documentation for when it is safe to convert from unsafe.Pointer to uintptr (http://tip.golang.org/pkg/unsafe/#Pointer). This code will very likely break in a future Go release.
The only safe way to implement this kind of thing is to add a handle on the Go side.
e969434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean that I should pass the argument as dummy of pointer, for example index of array of go pointers? I don't get understanding clearly. If you are okay, could you please give me your patch?
e969434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sent a pull request at #268 which shows the approach I mean.