-
Notifications
You must be signed in to change notification settings - Fork 281
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
panic: index out of range (sonar) #145
Comments
Is it possible that the test program has some background goroutines? |
I don't think so. It's for image manipulation. I'll double check |
Full panic message should contain all goroutines. |
Ok, I checked into this and I am using github.com/nfnt/resize and github.com/disintegration/imaging , which both use goroutines. Could try something like:
|
Then I think the problem is in // Sonar is called by instrumentation code to notify go-fuzz about comparisons.
// Low 8 bits of id are flags, the rest is unique id of a comparison.
func Sonar(v1, v2 interface{}, id uint32) {
...
pos := atomic.LoadUint32(&sonarPos)
for {
if pos+n > uint32(len(sonarRegion)) {
return
}
if atomic.CompareAndSwapUint32(&sonarPos, pos, pos+n) {
break
}
pos = atomic.LoadUint32(&sonarPos)
}
copy(sonarRegion[pos:pos+n], buf[:])
} While the increment is atomic, go-fuzz can see partially written data from background goroutines in sonarRegion, |
So if we add a mutex over the whole thing it should be okay. I can test that out. |
Unfortunately it's not that simple. |
Ideally we have some shared memory protocol that allows to understand what slots are fully-written and what are not. |
I tried adding a |
Are you also overriding runtime.GOMAXPROCS? go-fuzz sets GOMAXPROCS to 1. And I can't reproduce the crashes without overriding GOMAXPROCS. Both background goroutines and overriding GOMAXPROCS is bad for fuzzing? Can you remove at least overriding of GOMAXPROCS? It should fix crashes. |
I've submitted a reproducer for the bug. But it does not reproduce by default, only if runtime.GOMAXPROCS call is uncommented. I don't want to uncomment it, because it's not the recommended way of running go-fuzz. |
I'm not explicitly overriding GOMAXPROCS. I'll review all the code I'm importing to confirm. |
The race detector can find these bugs even with GOMAXPROCS=1. |
FYI, I'm not setting GOMAXPROCS anywhere. I could maybe build a test case that exhibits the bug. re race detection, I don't see where go-fuzz turns on race detection? |
That would be useful.
It doesn't. But if we want to catch these bugs with go-fuzz, it would be the right approach. |
add test for issue dvyukov#145
Even without a fix yet, it seems like we can add a note to the documentation about using go-fuzz with goroutines. |
What is the status on this ? (using go-fuzz with goroutines) |
I don't think anything has changed here since the last message. The Open status of the issue is still valid. |
Thanks. |
Seems the offending line is:
res = append(res, SonarSample{&ro.sonarSites[id], flags, [2][]byte{v1, v2}})
The text was updated successfully, but these errors were encountered: