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

[bug] - copy chunk before sending on chunksChan #1633

Merged
merged 3 commits into from
Aug 16, 2023

Conversation

ahrav
Copy link
Collaborator

@ahrav ahrav commented Aug 16, 2023

Description:

Memory Sharing Issues: I was sharing the chunk variable across iterations. When I update chunk.Data and send the pointer &chunk to the channel, all the chunks I was sending would point to the same memory. The change in one will affect all of them. If another goroutine is reading from the channel and modifying the chunk in parallel, we can run into concurrent read-write conflicts.

Create a new copy before passing it into the chunks chan.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@ahrav ahrav marked this pull request as ready for review August 16, 2023 22:02
@ahrav ahrav requested a review from a team as a code owner August 16, 2023 22:02
@ahrav
Copy link
Collaborator Author

ahrav commented Aug 16, 2023

Added an integration test to keep me honest!

@ahrav ahrav merged commit b8bb94f into main Aug 16, 2023
9 checks passed
@ahrav ahrav deleted the prevent-memory-sharing-s3-chunks branch August 16, 2023 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants