Skip to content

Potential deadlock in reorg() due to unreleased txLookupLock on error paths #34010

@userInner

Description

@userInner

In core/blockchain.go, the reorg function acquires a write lock via bc.txLookupLock.Lock(). However, several early return paths (specifically when bc.GetBlock returns nil) fail to call bc.txLookupLock.Unlock().

Lines leading to leak:

[Line 2651]: return errInvalidOldChain
[Line 2670]: return errInvalidOldChain
[Line 2685]: return errInvalidNewChain

This will cause any subsequent transaction lookups or further reorgs to hang indefinitely.

Proposed Fix:
Use defer bc.txLookupLock.Unlock() right after bc.txLookupLock.Lock() and remove the manual Unlock() at the end of the function to ensure the lock is always released.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions