-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy Histogram Buckets before sorting (#68)
Summary: go's sort.Sort function will occasionally modify the data that is passed into it even if that data is already sorted. (https://play.golang.org/p/QJ8kiJzzVG) For tally, this means that if a bucket slice is passed into tally, and tally calls sort.Sort on that slice, the slice will get modified inline (even if the list is already sorted). In practice, this means that if a user is using a single slice of buckets to create multiple tally histograms, there is a race condition where the shared bucket object could be modified mid-histogram creation. This PR creates copies of the []float64 and []time.Duration slices before sorting them, guaranteeing that we won't have a race condition.
- Loading branch information
Showing
2 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters