Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Go: Fix channel passing from Go to Rust by using
runtime.Pinner
orcgo.Handle
#3208base: main
Are you sure you want to change the base?
Go: Fix channel passing from Go to Rust by using
runtime.Pinner
orcgo.Handle
#3208Changes from 3 commits
65137d3
05c52c3
3ac02de
79647a8
aeca0cf
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Just to double check that this test achieve its goal without
-race
flag.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.
It also catches the same mistake I made with

cgo.Handle
.I was doing the following, which basically copied from the
cgo.Handle
example:But the &p.h suffers from the same problem as the payload channel. I have updated a corrected version:
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.
However,
unsafe.Pointer(p.h)
is not safe either, since acgo.Handle
is generated by an atomic counter and is not a valid memory address. Converting it to anunsafe.Pointer
could lead the Go runtime to do some wrong things.Therefore, in the latest version, I changed the pinner interface to return anWell,uintptr
instead and also updated callback signatures accordingly. f4529b9go vet
is not happy withuintptr->unsafe.Pointer
conversion either 🤔. Probably need to find another way to do the conversion.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.
Given that all the pinner functions get inlined, I think it is safe to do

unsafe.Pointer(p.h)
because it will be cast to uintptr immediately.