decred / dcrwallet

A secure Decred wallet daemon written in Go (golang).
https://decred.org
ISC License
211 stars 153 forks source link

nil BirthdayState defererence #2377

Closed buck54321 closed 2 weeks ago

buck54321 commented 3 weeks ago

In our dcrdex simnet harnesses, currently v2.0.1, I've seen a panic a couple of times at https://github.com/decred/dcrwallet/blob/f8cafb36df2764c677f0c2c951f9a797a5cfe147/wallet/udb/txmined.go#L352

Confirmed on v2.0.1. @JoeGruffins?

jrick commented 3 weeks ago

Please provide a stacktrace.

buck54321 commented 3 weeks ago
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x41 pc=0x896bea]

goroutine 1 [running]:
decred.org/dcrwallet/v4/wallet/udb.SetBirthState({0x100c420?, 0xc000080470?}, 0x0)
        /home/buck/github/decred/dcrwallet/wallet/udb/txmined.go:352 +0x6a
decred.org/dcrwallet/v4/wallet.(*Wallet).SetBirthState.func1({0x100c420?, 0xc000080470?})
        /home/buck/github/decred/dcrwallet/wallet/rescan.go:501 +0x25
decred.org/dcrwallet/v4/wallet/walletdb.Update({0x1009250, 0xc0000b29b0}, {0x100a100, 0xc00027c240}, 0xc0002207f0)
        /home/buck/github/decred/dcrwallet/wallet/walletdb/interface.go:252 +0x190
decred.org/dcrwallet/v4/wallet.(*Wallet).SetBirthState(0xc000041000?, {0x1009250?, 0xc0000b29b0?}, 0xc000219101?)
        /home/buck/github/decred/dcrwallet/wallet/rescan.go:500 +0x4e
main.createWallet({0x1009250, 0xc0000b29b0}, 0xc000083c00)
        /home/buck/github/decred/dcrwallet/walletsetup.go:251 +0x756
main.loadConfig({0x1009250, 0xc0000b29b0})
        /home/buck/github/decred/dcrwallet/config.go:682 +0x1ec7
main.run({0x1009250?, 0xc0000b29b0})
        /home/buck/github/decred/dcrwallet/dcrwallet.go:82 +0x4c
main.main()
        /home/buck/github/decred/dcrwallet/dcrwallet.go:53 +0x4a
JoeGruffins commented 2 weeks ago

Looking into it.

JoeGruffins commented 2 weeks ago

I think can only happen if you set with a nil birthday, will add a check for this.

Also I am concerned about what happens when this is called on an existing wallet. It should set a correct birthday block but it probably is not currently.

JoeGruffins commented 2 weeks ago

@buck54321 did you see this just running the harness?

buck54321 commented 2 weeks ago

Yeah I saw this just running the harness. I think it was the w-vspdwallet. It was when we were getting our dcrwallet v4 stuff worked out and I'm can't recall which version of vspd we were running.