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

storage: fix hasherstore seen panic #1700

Merged
merged 1 commit into from
Aug 29, 2019
Merged

storage: fix hasherstore seen panic #1700

merged 1 commit into from
Aug 29, 2019

Conversation

acud
Copy link
Member

@acud acud commented Aug 29, 2019

This PR fixes a panic that happens when the error returned from netstore.Put is not nil. In that case, the returned seen slice is empty, therefore resulting in a panic

@acud acud added the bug label Aug 29, 2019
@acud acud added this to the 0.5.0 milestone Aug 29, 2019
@acud acud requested review from janos and zelig August 29, 2019 06:18
@acud acud self-assigned this Aug 29, 2019
@acud acud changed the title storage: fix hasherstore seen check to happen when error is nil storage: fix hasherstore seen panic Aug 29, 2019
@@ -281,7 +281,7 @@ func (h *hasherStore) storeChunk(ctx context.Context, ch Chunk) {
}()
seen, err := h.store.Put(ctx, chunk.ModePutUpload, ch)
h.tag.Inc(chunk.StateStored)
if err != nil && seen[0] {
if err == nil && seen[0] {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the err is not nil? Does that not need any check?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, because that error is sent down the channel a few lines later, it is up to the context to handle that, not this function

Copy link
Contributor

@holisticode holisticode left a comment

Choose a reason for hiding this comment

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

I approve because this fixes the intended panic, but please check my comment

@acud acud merged commit 8dfc16e into master Aug 29, 2019
@acud
Copy link
Member Author

acud commented Aug 29, 2019

thanks @holisticode

@acud acud deleted the fix-hasherstore-put-err branch August 29, 2019 14:46
chadsr added a commit to chadsr/swarm that referenced this pull request Sep 23, 2019
* 'master' of github.com:ethersphere/swarm:
  pss: Modularize crypto and remove Whisper. Step 1 - isolate whisper code (ethersphere#1698)
  pss: Improve pressure backstop queue handling - no mutex (ethersphere#1695)
  cmd/swarm-snapshot: if 2 nodes to create snapshot use connectChain (ethersphere#1709)
  network: Add API for Capabilities (ethersphere#1675)
  pss: fixed flaky test that was using a global variable instead of a local one (ethersphere#1702)
  pss: Port tests to `network/simulation` (ethersphere#1682)
  storage: fix hasherstore seen check to happen when error is nil (ethersphere#1700)
  vendor: upgrade go-ethereum to 1.9.2 (ethersphere#1689)
  bzzeth: initial support for bzz-eth protocol (ethersphere#1571)
  network/stream: terminate runUpdateSyncing on peer quit (ethersphere#1696)
  all: first working SWAP version (ethersphere#1554)
  version: update to v0.5.0 unstable (ethersphere#1694)
  chunk, storage: storage with multi chunk Set method (ethersphere#1684)
  chunk, storage: add HasMulti to chunk.Store (ethersphere#1686)
  chunk, shed, storage: chunk.Store GetMulti method (ethersphere#1691)
  api, chunk: progress bar support (ethersphere#1649)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants