Skip to content

Commit

Permalink
fix: panic on using WaitGroup after it is freed (#1464)
Browse files Browse the repository at this point in the history
  • Loading branch information
brilliant-lx authored Apr 16, 2023
1 parent e4b6ab9 commit 2b0f568
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1584,18 +1584,20 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
}
}
// Garbage collect anything below our required write retention
wg2 := sync.WaitGroup{}
for !bc.triegc.Empty() {
root, number := bc.triegc.Pop()
if uint64(-number) > chosen {
bc.triegc.Push(root, number)
break
}
wg.Add(1)
wg2.Add(1)
go func() {
triedb.Dereference(root.(common.Hash))
wg.Done()
wg2.Done()
}()
}
wg2.Wait()
}
}
return nil
Expand Down

0 comments on commit 2b0f568

Please sign in to comment.