From 855cf6bb968e18a61378dc593a75f3db517fe4d8 Mon Sep 17 00:00:00 2001 From: Mayveskii Date: Wed, 18 Mar 2026 02:40:54 +0300 Subject: [PATCH] core: fix txLookupLock mutex leak on error returns in reorg() txLookupLock.Lock() was acquired without a matching defer, so any of the multiple early error returns inside reorg() left the mutex permanently locked. Subsequent reorgs or transaction lookups would deadlock. Replace the manual Unlock() at the happy-path exit with a deferred call placed immediately after Lock(), so all return paths release the lock. --- core/blockchain.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 8df2365072..42a8405ec9 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2628,6 +2628,7 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Header) error // as the txlookups should be changed atomically, and all subsequent // reads should be blocked until the mutation is complete. bc.txLookupLock.Lock() + defer bc.txLookupLock.Unlock() // Reorg can be executed, start reducing the chain's old blocks and appending // the new blocks @@ -2730,9 +2731,6 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Header) error // Reset the tx lookup cache to clear stale txlookup cache. bc.txLookupCache.Purge() - // Release the tx-lookup lock after mutation. - bc.txLookupLock.Unlock() - return nil }