-
Notifications
You must be signed in to change notification settings - Fork 7
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
cgo argument has Go pointer to Go pointer with Go v1.6.1 #4
Comments
This is a proposed solution for afbarnard#4.
I have to learn the new cgo rules and build Go 1.6 before I can fix this so it might be a few days. |
Thanks. |
An example of doing more or less what I described: https://github.com/golang/go/wiki/cgo#function-variables |
Since Go v1.6 Go code may pass a Go pointer to C provided that the Go memory to which it points does not contain any Go pointers. I create a synchronized map which stores all the go-objects we need to be able to retrive. registerCallback is used to register a new object and return its' index, lookupCallback returns the object by its' index, unregisterCallback unregisters an object from the map (callbackFunctions). Now instead of passing pointers to struct with a pointer, we pass a pointer to int which identifies the apropriate structure. Type assertion is used to convert interface{} to an actual object. We do this in order to have unified code for passing objective function callbacks and log function callbacks.
Hi, what do you think about #7? |
There are two possible workaround for those who are affected by the bug.
I hope eventually this gets fixed in the mainstream. |
I have use idavydov/go-lbfgsb.
So I have to use |
Hi @hiok2000 , According to your error, you are using in fact afbarnard/go-lbfgsb, not idavydov/go-lbfgsb. (E.g., see the line numbers; in idavydov version there are no function calls at the line 341). Could you try to make sure you are using idavydov/go-lbfgsb? Worst case, delete the directory manually or something similar. If you still observer this error in idavydov/go-lbfgsb, could you open a ticket there with a reproducible example ideally? |
I am sorry. You are right. I still use afbarnard/go-lbfgsb. I still got error in .f90 file in idavydov/go-lbfgsb. I replace .f90 and make file in idavydov/go-lbfgsb by .f30 and makefile afbarnard/go-lbfgsb. Everything is fine. I have get a good result using in my holtwinters forecast projects. Thank you both. |
It seems that the rules of passing pointer between C and Go changed golang/go#12416. Now example file generates a runtime error.
The text was updated successfully, but these errors were encountered: