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

Bug when hashing a file: Returned hash count is not always the same #1211

Closed
holisticode opened this issue Feb 8, 2019 · 2 comments
Closed

Comments

@holisticode
Copy link
Contributor

This problem appeared while working on #1185.

To reproduce it, one can run the TestGetAllReferences in swarm/storage/filestore_test.go, which is currently disabled on master due to this bug.

Running that test, the result is sometimes 247, sometimes 248 (which apparently should be the correct number), and sometimes even 246 for splitting a 1000000 bytes file.

This seems like a major bug and should be addressed soon.

@nolash
Copy link
Contributor

nolash commented Feb 8, 2019

The problem is a concurrency issue in your HashExplorer. If you add a mutex and lock the write to the HashExplorer.References array, the test passes every time.

It's hard to tell, but perhaps you also ideally should also call HasherStore.Wait() before you count the References in FileStore.GetAllReferences.

@holisticode
Copy link
Contributor Author

Closed by ethereum/go-ethereum#19028

zelig referenced this issue in ethereum/go-ethereum Feb 12, 2019
* swarm/storage: fix HashExplore concurrency bug ethersphere#1211

*  swarm/storage: lock as value not pointer

* swarm/storage: wait for  to complete

* swarm/storage: fix linter problems

* swarm/storage: append to nil slice
skylenet referenced this issue in holiman/go-ethereum Feb 19, 2019
…reum#19028)

* swarm/storage: fix HashExplore concurrency bug ethersphere#1211

*  swarm/storage: lock as value not pointer

* swarm/storage: wait for  to complete

* swarm/storage: fix linter problems

* swarm/storage: append to nil slice

(cherry picked from commit 3d22a46)
dshulyak referenced this issue in status-im/go-ethereum Mar 14, 2019
…reum#19028)

* swarm/storage: fix HashExplore concurrency bug ethersphere#1211

*  swarm/storage: lock as value not pointer

* swarm/storage: wait for  to complete

* swarm/storage: fix linter problems

* swarm/storage: append to nil slice

(cherry picked from commit 3d22a46)
kiku-jw referenced this issue in kiku-jw/go-ethereum Mar 29, 2019
…reum#19028)

* swarm/storage: fix HashExplore concurrency bug ethersphere#1211

*  swarm/storage: lock as value not pointer

* swarm/storage: wait for  to complete

* swarm/storage: fix linter problems

* swarm/storage: append to nil slice
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants