Skip to content

Fix ChunkStream buffer-reuse race causing corrupted stores#314

Merged
folbricht merged 1 commit intomasterfrom
issue-313
Mar 5, 2026
Merged

Fix ChunkStream buffer-reuse race causing corrupted stores#314
folbricht merged 1 commit intomasterfrom
issue-313

Conversation

@folbricht
Copy link
Owner

Fix a race condition in ChunkStream where the chunker's internal backing buffer could be overwritten by fillBuffer() before workers finished processing the slice sent through the channel. This caused desync tar -i to write chunks whose content didn't match their filename hash, producing stores that fail verification.

The bug was introduced in #307 which optimized fillBuffer() to reuse a backing buffer instead of allocating a fresh one each call. Single-threaded callers (like IndexFromFile) were unaffected since they hash the slice before the next Next() call, but ChunkStream sends the slice to worker goroutines via a channel.

Fixes #313

@folbricht folbricht merged commit f2a033f into master Mar 5, 2026
6 checks passed
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

Successfully merging this pull request may close these issues.

desync tar -i writes corrupted stores

1 participant