Skip to content

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

@calmh

Description

@calmh

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/[email protected]/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/[email protected]/fastcdc.go:110 +0x155
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions