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

core/bloombits: avoid crash when storing errors of different type #23437

Merged
merged 2 commits into from Aug 24, 2021

Conversation

otherview
Copy link
Contributor

When using atomic.Value it will panic if the error is a struct implementing the error interface and an error as been registered.

From https://pkg.go.dev/sync/atomic#Value.Store, Store sets the value of the Value to x. All calls to Store for a given Value must use values of the same concrete type. Store of an inconsistent type panics, as does Store(nil).

Check this example. https://play.golang.org/p/N5Zp15o_AoE

We recently found this error at https://github.com/ava-labs/ when a custom error was returned from rawdb.ReadBloomBits.
Kudos to https://github.com/StephenButtolph for writing the code.

@fjl fjl changed the title Store different error types core/bloombits: avoid crash when storing errors of different type Aug 23, 2021
@ligi
Copy link
Member

ligi commented Aug 24, 2021

Thanks for spotting this!

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, thanks

@holiman holiman added this to the 1.10.9 milestone Aug 24, 2021
@fjl fjl merged commit 8e0771c into ethereum:master Aug 24, 2021
sidhujag pushed a commit to sidhujag/go-ethereum that referenced this pull request Aug 24, 2021
…hereum#23437)

This fixes a rare crash which could occur when two different errors happened
in the same bloombits.MatcherSession.
reds pushed a commit to reds/go-ethereum that referenced this pull request Aug 28, 2021
…hereum#23437)

This fixes a rare crash which could occur when two different errors happened
in the same bloombits.MatcherSession.
yongjun925 pushed a commit to DODOEX/go-ethereum that referenced this pull request Dec 3, 2022
…hereum#23437)

This fixes a rare crash which could occur when two different errors happened
in the same bloombits.MatcherSession.
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.

None yet

4 participants