Skip to content

panic in WriteBlockWithState for very long low-td sidechain eventually beating canon chain #18977

Closed
@ryanschneider

Description

@ryanschneider

System information

Geth version: 1.8.22
OS & Version: Linux

Backtrace

INFO [01-31|20:34:43.732] Imported new chain segment               blocks=2048 txs=88    mgas=18.425   elapsed=819.636ms mgasps=22.480  number=819200 hash=341128…
INFO [01-31|20:34:43.815] Importing heavy sidechain segment        blocks=2048 start=819201 end=821248
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x1c0 pc=0x89e95a]
goroutine 359309 [running]:
github.com/ethereum/go-ethereum/core.(*BlockChain).WriteBlockWithState(0xc010364000, 0xc0f02a4090, 0x0, 0x0, 0x0, 0xc06916a0d0, 0x0, 0x0, 0x0)
        /ext-go/1/src/github.com/ethereum/go-ethereum/core/blockchain.go:976 +0xe7a
github.com/ethereum/go-ethereum/core.(*BlockChain).insertChain(0xc010364000, 0xc060afc000, 0x800, 0x900, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /ext-go/1/src/github.com/ethereum/go-ethereum/core/blockchain.go:1215 +0xcf7
github.com/ethereum/go-ethereum/core.(*BlockChain).insertSidechain(0xc010364000, 0xc06d5136a0, 0xc0000c30b0, 0xc0000c3001, 0x800, 0x800, 0xc0622aa000, 0x800, 0x80
        /ext-go/1/src/github.com/ethereum/go-ethereum/core/blockchain.go:1369 +0x1a3f
github.com/ethereum/go-ethereum/core.(*BlockChain).insertChain(0xc010364000, 0xc06b0b0000, 0x800, 0x800, 0x45beb41b51182401, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /ext-go/1/src/github.com/ethereum/go-ethereum/core/blockchain.go:1139 +0x2e15
github.com/ethereum/go-ethereum/core.(*BlockChain).InsertChain(0xc010364000, 0xc06b0b0000, 0x800, 0x800, 0x0, 0x0, 0x0)
        /ext-go/1/src/github.com/ethereum/go-ethereum/core/blockchain.go:1088 +0xb89
github.com/ethereum/go-ethereum/eth/downloader.(*Downloader).importBlockResults(0xc00020a820, 0xc06c0d6000, 0x800, 0x800, 0x800, 0x0)
        /ext-go/1/src/github.com/ethereum/go-ethereum/eth/downloader/downloader.go:1490 +0x40e
github.com/ethereum/go-ethereum/eth/downloader.(*Downloader).processFullSyncContent(0xc00020a820, 0x0, 0xc000051798)
        /ext-go/1/src/github.com/ethereum/go-ethereum/eth/downloader/downloader.go:1464 +0x79
github.com/ethereum/go-ethereum/eth/downloader.(*Downloader).processFullSyncContent-fm(0xc000000008, 0x1027608)
        /ext-go/1/src/github.com/ethereum/go-ethereum/eth/downloader/downloader.go:479 +0x2a
github.com/ethereum/go-ethereum/eth/downloader.(*Downloader).spawnSync.func1(0xc00020a820, 0xc034737620, 0xc01073fe60)
        /ext-go/1/src/github.com/ethereum/go-ethereum/eth/downloader/downloader.go:491 +0x59
created by github.com/ethereum/go-ethereum/eth/downloader.(*Downloader).spawnSync
        /ext-go/1/src/github.com/ethereum/go-ethereum/eth/downloader/downloader.go:491 +0xaf

The implication is that header is nil, which seems possible GetHeaderByNumber() returns nil if rawdb.ReadCanonicalHash()` returns an empty hash.

			// Find the next state trie we need to commit
			header := bc.GetHeaderByNumber(current - triesInMemory)
			chosen := header.Number.Uint64()  //header can be nil here

But, I'm not sure what err would be best to return in that case.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions