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:
CPerezz 2026-04-19 22:13:51 +02:00
parent 0c0c68da6c
commit 7f20e908e2
No known key found for this signature in database
GPG key ID: 62045F34B97177DD

View file

@ -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() {