mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
trie/bintrie: defer wg.Done in hashInternal shallow goroutine
If s.computeHash(node.left) panics inside the goroutine and a caller higher up recovers the panic, the parent would be stuck forever in wg.Wait() — no log, no error. defer wg.Done() releases the waiter unconditionally so Wait returns even on panic.
This commit is contained in:
parent
0c0c68da6c
commit
7f20e908e2
1 changed files with 4 additions and 1 deletions
|
|
@ -74,8 +74,11 @@ func (s *NodeStore) hashInternal(idx uint32) common.Hash {
|
|||
if !node.left.IsEmpty() {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
// defer wg.Done() so a panic in computeHash still releases
|
||||
// the waiter; without this, a recover() higher in the call
|
||||
// stack would leave the parent stuck in wg.Wait forever.
|
||||
defer wg.Done()
|
||||
lh = s.computeHash(node.left)
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
if !node.right.IsEmpty() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue