From 294a70646ec82d5804550df8c44f0af6683f94d3 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 14 Jan 2022 20:25:39 +0300 Subject: [PATCH] core: lock block addition on state jump It should be performed before we're able to process blocks or before we shutdown (which uses addition lock), fix panic: assignment to entry in nil map goroutine 5755 [running]: github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemoryStore).drop(...) /home/rik/dev/neo-go/pkg/core/storage/memory_store.go:74 github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemoryStore).PutChangeSet(0xc00093e700, 0xc0002051a0, 0xc000205200, 0x1, 0x1) /home/rik/dev/neo-go/pkg/core/storage/memory_store.go:100 +0x25c github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemoryStore).PutBatch(...) /home/rik/dev/neo-go/pkg/core/storage/memory_store.go:90 github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).removeOldStorageItems(0xc000206a00) /home/rik/dev/neo-go/pkg/core/blockchain.go:495 +0x33a created by github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).jumpToStateInternal /home/rik/dev/neo-go/pkg/core/blockchain.go:553 +0x68a FAIL github.com/nspcc-dev/neo-go/pkg/core 52.084s --- pkg/core/blockchain.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 73d923917..300f6a993 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -502,8 +502,10 @@ func (bc *Blockchain) removeOldStorageItems() { // specified by the state sync point p. All the data needed for the jump must be // collected by the state sync module. func (bc *Blockchain) jumpToState(p uint32) error { + bc.addLock.Lock() bc.lock.Lock() defer bc.lock.Unlock() + defer bc.addLock.Unlock() return bc.jumpToStateInternal(p, none) }