Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ethstats: prevent panic if head block is not available #29020

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

rjl493456442
Copy link
Member

This pull request fixes a flaw in ethstats.

The panic happens when the local blockchain is reorging which causes the original head block not reachable(number->hash canonical mapping is deleted). In order to prevent the panic, the block nilness will be checked in ethstats.

INFO [02-19|01:42:43.476] Chain reorg detected                     number=19,258,596 hash=9d98f1..e6fc8a drop=1 dropfrom=9e5d7e..e9aea2 add=1 addfrom=5c3ee3..9b5f97
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x100bdfa]

goroutine 4464 [running]:
github.com/ethereum/go-ethereum/core/types.(*Block).Header(...)
	github.com/ethereum/go-ethereum/core/types/block.go:356
github.com/ethereum/go-ethereum/ethstats.(*Service).assembleBlockStats(0xc000368360, 0x0)
	github.com/ethereum/go-ethereum/ethstats/ethstats.go:645 +0xba
github.com/ethereum/go-ethereum/ethstats.(*Service).reportBlock(0xc000368360, 0xc0b21b25b0?, 0xc0d185d330?)
	github.com/ethereum/go-ethereum/ethstats/ethstats.go:612 +0x25
github.com/ethereum/go-ethereum/ethstats.(*Service).report(0xc0161cbe00?, 0xc0161cbcbc?)
	github.com/ethereum/go-ethereum/ethstats/ethstats.go:527 +0x3b
github.com/ethereum/go-ethereum/ethstats.(*Service).loop(0xc000368360, 0xc00085d3e0, 0xc00085d4a0)
	github.com/ethereum/go-ethereum/ethstats/ethstats.go:334 +0x9bf
created by github.com/ethereum/go-ethereum/ethstats.(*Service).Start in goroutine 1
	github.com/ethereum/go-ethereum/ethstats/ethstats.go:210 +0x127

@rjl493456442 rjl493456442 added this to the 1.13.13 milestone Feb 19, 2024
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@holiman holiman merged commit 034bc46 into ethereum:master Feb 19, 2024
3 checks passed
jorgemmsilva pushed a commit to iotaledger/go-ethereum that referenced this pull request Jun 17, 2024
This pull request fixes a flaw in ethstats which can lead to node crash

A panic could happens when the local blockchain is reorging which causes the original head block not to be  reachable (since number->hash canonical mapping is deleted). In order to prevent the panic, the block nilness is now checked in ethstats.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants