ava-labs / avalanchego

Go implementation of an Avalanche node.
https://avax.network
BSD 3-Clause "New" or "Revised" License
2.11k stars 664 forks source link

segfault when --tracing-enabled is set #3329

Closed blenessy closed 2 weeks ago

blenessy commented 2 weeks ago

Describe the bug Then the optional --tracing-enabled configuration option is used you get the following segfault on startup:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xb28684]
goroutine 2609 [running]:
github.com/ava-labs/avalanchego/snow/engine/common.(*tracedBootstrapableEngine).Clear(0xc036349ec0, {0x21e17b8?, 0x3f3af>
        /home/runner/work/avalanchego-internal/avalanchego-internal/snow/engine/common/traced_bootstrapable_engine.go:28>
github.com/ava-labs/avalanchego/snow/networking/handle r.(*handler).selectStartingGear(0xc04db77600, {0x21e17b8, 0x3f3af4>
        /home/runner/work/avalanchego-internal/avalanchego-internal/snow/networking/handler/handler.go:235 +0xbb
github.com/ava-labs/avalanchego/snow/networking/handler.(*handler).Start(0xc04db77600, {0x21e17b8, 0x3f3af40}, 0x0)
        /home/runner/work/avalanchego-internal/avalanchego-internal/snow/networking/handler/handler.go:239 +0x45
github.com/ava-labs/avalanchego/chains.(*manager).createChain(0xc008df4000, {{0x4, 0x27, 0xd4, 0xb2, 0x2a, 0x2a, 0x78, 0>
        /home/runner/work/avalanchego-internal/avalanchego-internal/chains/manager.go:472 +0x1a64
github.com/ava-labs/avalanchego/chains.(*manager).dispatchChainCreator(0xc008df4000)
        /home/runner/work/avalanchego-internal/avalanchego-internal/chains/manager.go:1517 +0x125
created by github.com/ava-labs/avalanchego/chains.(*manager).StartChainCreator in goroutine 1
        /home/runner/work/avalanchego-internal/avalanchego-internal/chains/manager.go:1494 +0x127

To Reproduce Use the --tracing-enabled cli argument at startup

Expected behavior No segfault.

Operating System Debian 12 (Bookworm) on AMD64

blenessy commented 2 weeks ago

For preventing this kind of bugs in the future I suggest that you enable exhaustruct in .golangci.yml.

StephenButtolph commented 2 weeks ago

Thanks for pointing this out!