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

calling wallet.Stop() at application exit results in an error #282

Closed
manan19 opened this issue May 15, 2015 · 2 comments
Closed

calling wallet.Stop() at application exit results in an error #282

manan19 opened this issue May 15, 2015 · 2 comments
Assignees

Comments

@manan19
Copy link
Contributor

manan19 commented May 15, 2015

It doesn't happen 100% of the times, so probably a race condition somewhere.

panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
    [signal 0xb code=0x1 addr=0x18 pc=0x43f37b5]

    goroutine 51 [running]:
            github.com/btcsuite/bolt.(*freelist).rollback(0x0, 0x77)
    go/src/github.com/btcsuite/bolt/freelist.go:144 +0x35
            github.com/btcsuite/bolt.(*Tx).rollback(0xc20801ec30)
    go/src/github.com/btcsuite/bolt/tx.go:223 +0x5c
            github.com/btcsuite/bolt.func·010()
    go/src/github.com/btcsuite/bolt/db.go:497 +0x38
            github.com/btcsuite/bolt.(*Tx).write(0xc20801ec30, 0x0, 0x0)
    go/src/github.com/btcsuite/bolt/tx.go:428 +0x350
            github.com/btcsuite/bolt.(*Tx).Commit(0xc20801ec30, 0x0, 0x0)
    go/src/github.com/btcsuite/bolt/tx.go:176 +0x47c
            github.com/btcsuite/bolt.(*DB).Update(0xc208035380, 0xc2183e1d10, 0x0, 0x0)
    go/src/github.com/btcsuite/bolt/db.go:512 +0x169
                    github.com/btcsuite/btcwallet/walletdb/bdb.(*namespace).Update(0xc2080c34e0, 0xc2080c33a0, 0x0, 0x0)
    go/src/github.com/btcsuite/btcwallet/walletdb/bdb/db.go:348 +0x66
                github.com/btcsuite/btcwallet/waddrmgr.(*Manager).SetSyncedTo(0xc208034680, 0xc2080cc930, 0x0, 0x0)
    go/src/github.com/btcsuite/btcwallet/waddrmgr/sync.go:221 +0x37a
                github.com/btcsuite/btcwallet/wallet.(*Wallet).syncWithChain(0xc2080daa20, 0x0, 0x0)
    go/src/github.com/btcsuite/btcwallet/wallet/wallet.go:433 +0x40f
                github.com/btcsuite/btcwallet/wallet.func·001(0xc2080daa20)
    go/src/github.com/btcsuite/btcwallet/wallet/chainntfns.go:32 +0x2b
    created by github.com/btcsuite/btcwallet/wallet.(*Wallet).handleChainNotifications
    go/src/github.com/btcsuite/btcwallet/wallet/chainntfns.go:42 +0x438
@manan19 manan19 changed the title calling wallet.Stop() at application exit results in error calling wallet.Stop() at application exit results in an error May 15, 2015
@jrick
Copy link
Member

jrick commented Mar 9, 2016

This is due to bolt transactions still being active while the database is closed. I will look into adding a mutex in walletdb to prevent this from happening.

@jrick jrick self-assigned this Mar 9, 2016
@jrick
Copy link
Member

jrick commented Mar 9, 2016

Actually, this could be a different issue. The MMIO issues caused by closing the db with active transactions will result in the process segfaulting, but this appears to be a panic from a nil pointer dereference (which the language enforces null pointer checks on before dereferencing, so there can never be a segfault).

jrick added a commit to jrick/btcwallet that referenced this issue Mar 11, 2016
This corrects and simplifies the shutdown logic for interrupts, the
walletrpc.WalletLoaderService/CloseWallet RPC, and the legacy stop RPC
by both stopping all wallet processes and closing the wallet database.
It appears that this behavior broke as part of the wallet package
refactor, causing occasional nil pointer panics and memory faults when
closing the wallet database with active transactions.

Fixes btcsuite#282.

Fixes btcsuite#283.
jrick added a commit to jrick/btcwallet that referenced this issue Mar 11, 2016
This corrects and simplifies the shutdown logic for interrupts, the
walletrpc.WalletLoaderService/CloseWallet RPC, and the legacy stop RPC
by both stopping all wallet processes and closing the wallet database.
It appears that this behavior broke as part of the wallet package
refactor, causing occasional nil pointer panics and memory faults when
closing the wallet database with active transactions.

Fixes btcsuite#282.

Fixes btcsuite#283.
cjepson pushed a commit to cjepson/btcwallet that referenced this issue Jul 27, 2016
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

No branches or pull requests

2 participants