From 7f20e908e2a9dfe32617f2ea9339970c6b5f9efb Mon Sep 17 00:00:00 2001 From: CPerezz Date: Sun, 19 Apr 2026 22:13:51 +0200 Subject: [PATCH] trie/bintrie: defer wg.Done in hashInternal shallow goroutine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- trie/bintrie/store_commit.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trie/bintrie/store_commit.go b/trie/bintrie/store_commit.go index 5e3195e9e4..a60bc61697 100644 --- a/trie/bintrie/store_commit.go +++ b/trie/bintrie/store_commit.go @@ -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() {