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

tx.Check() crashes in read-only database #45

Closed
dmoklaf opened this issue Sep 12, 2017 · 1 comment
Closed

tx.Check() crashes in read-only database #45

dmoklaf opened this issue Sep 12, 2017 · 1 comment
Labels

Comments

@dmoklaf
Copy link
Contributor

dmoklaf commented Sep 12, 2017

When the database db is opened in read-only mode (options = bolt.Options{ReadOnly: true}),
and the transaction tx is created in read-only mode (tx, ... = db.Begin(false))

Then calls to tx.Check() will systematically crash the process (stack traces at bottom of this message).
It seems the freelist management code is not entirely aware of limitations of the read-only mode - more particularly nil instances.


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

goroutine 18 [running]:
github.com/coreos/bbolt.(*freelist).free_count(...)
xxx/src/github.com/coreos/bbolt/freelist.go:52
github.com/coreos/bbolt.(*freelist).count(0x0, 0x0)
xxx/src/github.com/coreos/bbolt/freelist.go:47 +0x22
github.com/coreos/bbolt.(*Tx).check(0xc4200ca000, 0xc4200ce000)
xxx/src/github.com/coreos/bbolt/tx.go:396 +0xdb
created by github.com/coreos/bbolt.(*Tx).Check
xxx/src/github.com/coreos/bbolt/tx.go:389 +0x67

@lorneli
Copy link
Contributor

lorneli commented Sep 12, 2017

When db is in read-only mode, db.freelist is not initialized in Open function. https://github.com/coreos/bbolt/blob/master/db.go#L254

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants