Skip to content
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

Bad use of package global causes data race, clobbered chunkers #4

Open
calmh opened this issue Oct 5, 2020 · 0 comments
Open

Bad use of package global causes data race, clobbered chunkers #4

calmh opened this issue Oct 5, 2020 · 0 comments

Comments

@calmh
Copy link

calmh commented Oct 5, 2020

Hi! Thanks for this implementation!

I noticed that while it looks like NewChunker returns a new chunker based on the given options, it actually depends on the global table variable, meaning two chunkers with different seed values will stomp on each other, and chunkers cannot be constructed concurrently without causing a data race.

WARNING: DATA RACE
Read at 0x00000594c720 by goroutine 163:
  github.com/jotfs/fastcdc-go.NewChunker()
      /Users/jb/go/pkg/mod/github.com/jotfs/fastcdc-go@v0.2.0/fastcdc.go:110 +0x124
...

Previous write at 0x00000594c720 by goroutine 206:
  github.com/jotfs/fastcdc-go.NewChunker()
      /Users/jb/go/pkg/mod/github.com/jotfs/fastcdc-go@v0.2.0/fastcdc.go:110 +0x155
...
calmh added a commit to kastelo-labs/fastcdc-go that referenced this issue Oct 5, 2020
Instead copy it when we want to use a new seed.

Fixes the example test which in fact had incorrect output when run on
its own, depending on the old behavior of someone else having clobbered
the global table previously.
pbtrung added a commit to pbtrung/fastcdc-go that referenced this issue Dec 22, 2020
pbtrung added a commit to pbtrung/fastcdc-go that referenced this issue Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant