utreexo / utreexod

A fully validating Bitcoin node with Utreexo support
ISC License
90 stars 21 forks source link

Crash while running with `--prune=550` #78

Closed Davidson-Souza closed 1 year ago

Davidson-Souza commented 1 year ago

While running on signet with the following command: utreexod --signet --utreexo --nolisten --notls --prune=550. If I don't use --prune it doesn't run on this error.

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x6be8fe]

goroutine 83 [running]:
github.com/utreexo/utreexod/database/ffldb.rollbackOnPanic(0xc004a03450)
    utreexod/database/ffldb/db.go:2221 +0x56
panic({0x9539c0?, 0xf2c280?})
    /usr/lib/go/src/runtime/panic.go:914 +0x21f
github.com/utreexo/utreexod/blockchain.(*BlockChain).connectBlock.func1({0xc0a1e8, 0xc004a03450})
    utreexod/blockchain/chain.go:641 +0x27e
github.com/utreexo/utreexod/database/ffldb.(*db).Update(0xc0091ae7e0?, 0xc0061c7630)
    utreexod/database/ffldb/db.go:2278 +0x7e
github.com/utreexo/utreexod/blockchain.(*BlockChain).connectBlock(0xc0000fb6c0, 0xc0091ae7e0, 0xc0028ac3f0, 0x0, {0xc00068ea00, 0x10, 0x10})
    utreexod/blockchain/chain.go:628 +0x3b8
github.com/utreexo/utreexod/blockchain.(*BlockChain).connectBestChain(0xc0000fb6c0, 0xc0091ae7e0, 0xc0028ac3f0, 0x0)
    utreexod/blockchain/chain.go:1408 +0x4cc
github.com/utreexo/utreexod/blockchain.(*BlockChain).maybeAcceptBlock(0xc0000fb6c0, 0xc0028ac3f0, 0xc05c90?)
    utreexod/blockchain/accept.go:81 +0x1a7
github.com/utreexo/utreexod/blockchain.(*BlockChain).ProcessBlock(0xc0000fb6c0, 0xc0028ac3f0, 0x0)
    utreexod/blockchain/process.go:281 +0x30d
github.com/utreexo/utreexod/netsync.(*SyncManager).handleBlockMsg(0xc000276000, 0xc00220a4c8)
    utreexod/netsync/manager.go:727 +0x2ae
github.com/utreexo/utreexod/netsync.(*SyncManager).blockHandler(0xc000276000)
    utreexod/netsync/manager.go:1421 +0x1e5
created by github.com/utreexo/utreexod/netsync.(*SyncManager).Start in goroutine 16
    utreexod/netsync/manager.go:1670 +0xc6

If I use --prune=550 but not --utreexo, I also get an error.

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x6be8fe]

goroutine 59 [running]:
github.com/utreexo/utreexod/database/ffldb.rollbackOnPanic(0xc020dc81a0)
    utreexod/database/ffldb/db.go:2221 +0x56
panic({0x9539c0?, 0xf2c280?})
    /usr/lib/go/src/runtime/panic.go:914 +0x21f
github.com/utreexo/utreexod/blockchain.(*BlockChain).connectBlock.func1({0xc0a1e8, 0xc020dc81a0})
    utreexod/blockchain/chain.go:641 +0x27e
github.com/utreexo/utreexod/database/ffldb.(*db).Update(0xc00f019c00?, 0xc014fd27d0)
    utreexod/database/ffldb/db.go:2278 +0x7e
github.com/utreexo/utreexod/blockchain.(*BlockChain).connectBlock(0xc00011e680, 0xc00f019c00, 0xc000024630, 0x0, {0xc0007b4000, 0x46, 0x46})
    utreexod/blockchain/chain.go:628 +0x3b8
github.com/utreexo/utreexod/blockchain.(*BlockChain).connectBestChain(0xc00011e680, 0xc00f019c00, 0xc000024630, 0x0)
    utreexod/blockchain/chain.go:1408 +0x4cc
github.com/utreexo/utreexod/blockchain.(*BlockChain).maybeAcceptBlock(0xc00011e680, 0xc000024630, 0xc05c90?)
    utreexod/blockchain/accept.go:81 +0x1a7
github.com/utreexo/utreexod/blockchain.(*BlockChain).ProcessBlock(0xc00011e680, 0xc000024630, 0x0)
    utreexod/blockchain/process.go:281 +0x30d
github.com/utreexo/utreexod/netsync.(*SyncManager).handleBlockMsg(0xc000488000, 0xc011b2c660)
    utreexod/netsync/manager.go:727 +0x2ae
github.com/utreexo/utreexod/netsync.(*SyncManager).blockHandler(0xc000488000)
    utreexod/netsync/manager.go:1421 +0x1e5
created by github.com/utreexo/utreexod/netsync.(*SyncManager).Start in goroutine 53
    utreexod/netsync/manager.go:1670 +0xc6
kcalvinalvin commented 1 year ago

Oh shoot I'll take a look

kcalvinalvin commented 1 year ago

I think it's not checking that the datadir hasn't been previously created by a non-utreexo node

Did you run a non-utreexo node before running that command? Could you clear the datadir and see if the same bug happens?

EDIT: Works fine for me when synced with a fresh datadir.

EDIT, EDIT: I see the bug now. Am able to reproduce it

kcalvinalvin commented 1 year ago

Fixed by #79