From ba068d40dd9a198ccc7ad9382c768f363aeb54cc Mon Sep 17 00:00:00 2001 From: Boqin Qin Date: Mon, 27 Apr 2020 21:16:30 +0800 Subject: [PATCH] core: add check in AddChildIndexer to avoid double lock (#20982) This fixes a theoretical double lock condition which could occur in indexer.AddChildIndexer(indexer) Nobody would ever do that though. Co-authored-by: Felix Lange --- core/chain_indexer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/chain_indexer.go b/core/chain_indexer.go index c0c2c4f7f..1bff3aee7 100644 --- a/core/chain_indexer.go +++ b/core/chain_indexer.go @@ -439,6 +439,9 @@ func (c *ChainIndexer) Sections() (uint64, uint64, common.Hash) { // AddChildIndexer adds a child ChainIndexer that can use the output of this one func (c *ChainIndexer) AddChildIndexer(indexer *ChainIndexer) { + if indexer == c { + panic("can't add indexer as a child of itself") + } c.lock.Lock() defer c.lock.Unlock()