-
Notifications
You must be signed in to change notification settings - Fork 9
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
New Go<->cgo pointer rules in 1.6 don't like gocairo #3
Comments
More panic output:
|
Thanks for the report! It's because I pass one of these through C: type writeClosure struct {
w io.Writer
err error
} and I guess that's no longer allowed. I'm not exactly sure how they expect me to wrap an API like this |
Probably need to ask Ian on golang-nuts.. I'm sure lots of people will be hit by this. |
I got a comment from Ian himself! The design doc suggests this pattern:
I will write a patch this weekend hopefully. |
Were you able to find a solution? |
I talked to Ian separately. The fix unfortunately is to use a map of pending writes. I haven't had time to work on this but I hope to get to it soon. See E.g. var closures = map[int]*writeClosure{}
var closuresLock sync.Mutex
// Then when calling into the C API from our wrapper, something like:
closuresLock.Lock()
closures[x] = &writeClosure{...}
closuresLock.Unlock()
C.cairo_whatever(..., x)
closuresLock.Lock()
delete(closures, x)
closuresLock.Unlock()
...
and similarly on the other side we look up the closure with a key.
This is what Ian suggested anyway. Pretty gross. |
Is that conversation public? I don't understand how a mutex would change things. (The mutex is needed for concurrent map access, but the |
Yes, but instead of passing the writeClosure to C, you pass the key (an integer) to the entry in the map. |
How would you reference the map from C? |
Please let me know if 6a65339 (on master) fixes the problem. I wrote it blind (I don't have Go 1.6 locally) but I think it should work. |
Oops, and to answer the earlier question, no the conversation wasn't public. But as I pasted above the design doc from when they made this change had a sentence or two about doing this. |
Yup; works here. Thanks! |
You're the first user of this library I've heard from, so please feel free
to make feature requests etc. if you have any!
|
Everything works here, too. Thank you, @martine! |
@martine The only feature I'm missing is svg output. I'll file a bug for that. |
While running https://github.com/dgryski/carbonapi with Go 1.6rc2, I got
http: panic serving 127.0.0.1:44456: runtime error: cgo argument has Go pointer to Go pointer
This error didn't happen with 1.5.
The text was updated successfully, but these errors were encountered: