-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Bug in the way that data is passed down to callback functions #22
Comments
At this point this is just an experiment. It causes go vet to raise a warning, so these needs further validation before merging.
This fix seems to work, but I'm not familiarized yet with With that fix |
I have been able to reproduce the issue with Go 1.8.5 but not with Go 1.9.2 (Debian unstable/amd64). What version are you using? My belief is that the garbage collector collects |
I have Go 1.8 too. Your belief makes sense. At first I thought that too, but then read that the GC doesn't free the object if you hold an unsafe.Pointer to it, and discarded the idea. What I didn't noticed is that the pointer is not hold by the function neither, so nothing prevents the GC from freeing |
BTW, what do you think about plusvic@7275017, I believe it's safe even if |
I have gone through a few iterations of trying to use integers / uintptr values where the Go compiler and/or runtime thought it was passing pointers around. It would work with the then-current compiler/runtime version but then the CGO rules (which are underdocumented anyway) would get changed and things would break. At this point I have pretty much given up on that idea. Let's see if explicitly keeping the id values alive will do the trick... |
Let's see what the Travis CI setup comes up with... |
Woohoo, it crashed with every Go version but tip. |
Ah well, it seems like the keepAlive function for go 1.6 also has a beneficial effect in this case. I am getting too old for this nonsense. |
While investigating some other issue I accidentally hit a bug that seems related to the mechanism for passing data to callback functions. By adding the following test case to
rules_test.go
you should be able to trigger the bug:The bug can manifest itself in two ways, by panicing in line 44 of callback-util.go or by raising the following error:
In my case commenting out the line
fmt.Println("GC")
switch from one error to the other, but your mileage may vary. It was the panic incallback-util.go
what lead me find a possible explanation for what's happening.Take a look at this:
This passes to the callback the address of
id
, as an unsafe.Pointer. My theory is that the garbage collector is movingid
around beforecompilerCallback
is called. By the timecompilerCallback
is called the address whereid
was previously stored contains different data.Thoughts?
The text was updated successfully, but these errors were encountered: