Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When using a wg Add is intended to be called before wait, calling Add and Wait concurrently leads to data races, and the blockchain calls Add all over the place in many public methods that can be called from other threads. The solution is to lock over calls to Add and Wait. Unfortunately we can't see both sides of this data race, it seems the stack was corrupted somehow since the first stack trace cannot be correct (how can fmt.Fscanf call TestStartStopValidators ?). Ive shortened the stack with an elipsis because it was also very long. But it seems clear that this violation was occurring. golang/go#23842 ================== WARNING: DATA RACE Write at 0x00c007036360 by goroutine 354: internal/race.Write() /usr/local/go/src/internal/race/race.go:41 +0x125 sync.(*WaitGroup).Wait() /usr/local/go/src/sync/waitgroup.go:128 +0x126 github.com/celo-org/celo-blockchain/core.(*BlockChain).Stop() /home/pierspowlesland/projects/celo-blockchain/core/blockchain.go:987 +0xfd github.com/celo-org/celo-blockchain/eth.(*Ethereum).Stop() /home/pierspowlesland/projects/celo-blockchain/eth/backend.go:584 +0x216 github.com/celo-org/celo-blockchain/node.(*Node).stopServices() /home/pierspowlesland/projects/celo-blockchain/node/node.go:309 +0x150 github.com/celo-org/celo-blockchain/node.(*Node).Close() /home/pierspowlesland/projects/celo-blockchain/node/node.go:221 +0x1bb github.com/celo-org/celo-blockchain/test.(*Node).Close() /home/pierspowlesland/projects/celo-blockchain/test/node.go:312 +0x3b8 github.com/celo-org/celo-blockchain/test.Network.Shutdown() /home/pierspowlesland/projects/celo-blockchain/test/node.go:498 +0x9a runtime.call32() /usr/local/go/src/runtime/asm_amd64.s:551 +0x3d testing.(*T).FailNow() <autogenerated>:1 +0x44 github.com/stretchr/testify/require.NoError() /home/pierspowlesland/go/pkg/mod/github.com/stretchr/testify@v1.4.0/require/require.go:974 +0x104 github.com/celo-org/celo-blockchain/e2e_test_test.TestStartStopValidators() /home/pierspowlesland/projects/celo-blockchain/e2e_test/e2e_test.go:168 +0x15ce fmt.Fscanf() /usr/local/go/src/fmt/scan.go:143 +0xee fmt.Sscanf() /usr/local/go/src/fmt/scan.go:114 +0x191 github.com/syndtr/goleveldb/leveldb/storage.fsParseName() /home/pierspowlesland/go/pkg/mod/github.com/syndtr/goleveldb@v1.0.1-0.20190923125748-758128399b1d/leveldb/storage/file_storage.go:643 +0xa6 github.com/syndtr/goleveldb/leveldb/storage.(*fileStorage).List() /home/pierspowlesland/go/pkg/mod/github.com/syndtr/goleveldb@v1.0.1-0.20190923125748-758128399b1d/leveldb/storage/file_storage.go:458 +0x309 github.com/syndtr/goleveldb/leveldb.(*DB).checkAndCleanFiles() /home/pierspowlesland/go/pkg/mod/github.com/syndtr/goleveldb@v1.0.1-0.20190923125748-758128399b1d/leveldb/db_util.go:52 +0x301 github.com/syndtr/goleveldb/leveldb.openDB() /home/pierspowlesland/go/pkg/mod/github.com/syndtr/goleveldb@v1.0.1-0.20190923125748-758128399b1d/leveldb/db.go:136 +0x9bb fmt.(*ss).doScanf() /usr/local/go/src/fmt/scan.go:1230 +0x411 fmt.Fscanf() /usr/local/go/src/fmt/scan.go:143 +0xee fmt.Sscanf() ... Previous read at 0x00c001448520 by goroutine 203: [failed to restore the stack]
- Loading branch information