Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Is / should gofuzz safe for concurrent use? #69

Closed
alarbada opened this issue Dec 8, 2022 · 2 comments
Closed

Is / should gofuzz safe for concurrent use? #69

alarbada opened this issue Dec 8, 2022 · 2 comments

Comments

@alarbada
Copy link

alarbada commented Dec 8, 2022

I've had several data races with stack traces like this:

  math/rand.(*rngSource).Uint64()
      /usr/local/go/src/math/rand/rng.go:249 +0x190
  math/rand.(*rngSource).Int63()
      /usr/local/go/src/math/rand/rng.go:234 +0x1f1
  math/rand.(*Rand).Int63()
      /usr/local/go/src/math/rand/rand.go:84 +0x70
  math/rand.(*Rand).Int31()
      /usr/local/go/src/math/rand/rand.go:98 +0x81
  math/rand.(*Rand).Int31n()
      /usr/local/go/src/math/rand/rand.go:133 +0x45
  math/rand.(*Rand).Intn()
      /usr/local/go/src/math/rand/rand.go:171 +0x48
  github.com/google/gofuzz.UnicodeRanges.randString()
      /home/guillem/golang/pkg/mod/github.com/google/gofuzz@v1.2.0/fuzz.go:586 +0x48
  github.com/google/gofuzz.randString()
      /home/guillem/golang/pkg/mod/github.com/google/gofuzz@v1.2.0/fuzz.go:598 +0x6f
  github.com/google/gofuzz.glob..func6()
      /home/guillem/golang/pkg/mod/github.com/google/gofuzz@v1.2.0/fuzz.go:491 +0x70
  github.com/google/gofuzz.(*fuzzerContext).doFuzz()
      /home/guillem/golang/pkg/mod/github.com/google/gofuzz@v1.2.0/fuzz.go:271 +0x76e
  github.com/google/gofuzz.(*fuzzerContext).doFuzz()
      /home/guillem/golang/pkg/mod/github.com/google/gofuzz@v1.2.0/fuzz.go:302 +0xa29
  github.com/google/gofuzz.(*fuzzerContext).doFuzz()
      /home/guillem/golang/pkg/mod/github.com/google/gofuzz@v1.2.0/fuzz.go:327 +0x946
  github.com/google/gofuzz.(*Fuzzer).fuzzWithContext()
      /home/guillem/golang/pkg/mod/github.com/google/gofuzz@v1.2.0/fuzz.go:239 +0x224
  github.com/google/gofuzz.(*Fuzzer).Fuzz()
      /home/guillem/golang/pkg/mod/github.com/google/gofuzz@v1.2.0/fuzz.go:213 +0x18e

so, I guess it is not. Should it be?

@lavalamp
Copy link
Contributor

lavalamp commented Dec 8, 2022

The expectation is that you'll just construct a fuzzer per goroutine (use different seeds!), that will give better performance than internally locking the rng.

@alarbada
Copy link
Author

alarbada commented Dec 9, 2022

Cool, thanks

@alarbada alarbada closed this as completed Dec 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants