Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

network/stream: fix slice append bug #1924

Merged
merged 1 commit into from
Nov 4, 2019
Merged

network/stream: fix slice append bug #1924

merged 1 commit into from
Nov 4, 2019

Conversation

acud
Copy link
Member

@acud acud commented Nov 1, 2019

This PR fixes a bug in stream package where a slice representing the wanted hashes on a 0 wanted hashes message was appended to, instead of setting the slice elements which were preallocated. This resulted in the first len(msg.Hashes) to be zero address hashes, and the second len(msg.Hashes) to be the actual hashes.
In turn, in localstore.Set this caused an error (since the zero address chunk returned an error because it does not exist) and the rest of the hashes were not set, since the error handling in Set bails directly on the first error, instead of continuing to set the rest of the chunk addresses in the variadic function parameters.

We should probably consider our error handling on if we bail immediately on error on these kind of operations. Maybe a potential partial set in this case would have prevented the problem (while masking the bug).

@acud acud added the bug label Nov 1, 2019
@acud acud added this to the 0.5.3 milestone Nov 1, 2019
@acud acud requested review from janos and zelig November 1, 2019 17:06
@acud acud self-assigned this Nov 1, 2019
@acud acud added this to Backlog in Swarm Core - Sprint planning via automation Nov 1, 2019
@acud acud moved this from Backlog to In review (includes Documentation) in Swarm Core - Sprint planning Nov 1, 2019
Copy link
Member

@janos janos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an amazing find and a huge bug. Thank you @acud.

@zelig zelig merged commit e89acee into master Nov 4, 2019
Swarm Core - Sprint planning automation moved this from In review (includes Documentation) to Done Nov 4, 2019
@acud acud deleted the fix-stream-quirk branch November 4, 2019 07:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants