application crash if db file is corrupted
Author: cbrakeCreated Apr 14, 2017Updated Jan 9, 2018
If I delete a few bytes from the beginning of a bolt db file, I get an application seg fault:
pwlog-test
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4a4348]
goroutine 1 [running]:
bec.com/vendor/github.com/boltdb/bolt.(*DB).Close(0x0, 0x0, 0x0)
/scratch/go/src/bec.com/vendor/github.com/boltdb/bolt/db.go:392 +0x38
main.main()
/scratch/go/src/bec.com/cmd/pwlog-test/pwlog-test.go:26 +0x1ea
exit status 2This is probably expected, but I'm wondering if there is any way to run a check on the file so we can handle the errors in the application (perhaps reset the db file, etc)?
Thanks!
Source: boltdb/bolt