WSL: BoltDB panics on cursor search since April update
-
Your Windows build number: Microsoft Windows [Version 10.0.17134.1]
-
What you’re doing and what’s happening
- Make sure GO is installed
- run:
go get github.com/boltdb/bolt - Put the following code in a file named main.go:
package main
import (
"fmt"
"log"
"os"
"github.com/boltdb/bolt"
)
func main() {
os.Remove("test.db")
db, err := bolt.Open("test.db", 0600, nil)
if err != nil {
log.Fatal(err)
}
defer db.Close()
db.Update(func(tx *bolt.Tx) error {
_, err := tx.CreateBucket([]byte("MyBucket"))
if err != nil {
return fmt.Errorf("create bucket: %s", err)
}
return err
})
db.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("MyBucket"))
c := b.Cursor()
c.Seek([]byte("test"))
return nil
})
os.Remove("test.db")
}
- Run
go build main.go - Run
./main
- What’s wrong / what should be happening instead: BoltDB panics with:
panic: invalid page type: 0: 4
goroutine 1 [running]:
github.com/boltdb/bolt.(*Cursor).search(0xc420043da8, 0xc420043e80, 0x8, 0x20, 0x4)
/mnt/d/go/src/github.com/boltdb/bolt/cursor.go:256 +0x388
github.com/boltdb/bolt.(*Cursor).seek(0xc420043da8, 0xc420043e80, 0x8, 0x20, 0x0, 0x0, 0xc420043d80, 0x8, 0x8, 0xc42000c040, ...)
/mnt/d/go/src/github.com/boltdb/bolt/cursor.go:159 +0xa5
github.com/boltdb/bolt.(*Bucket).Bucket(0xc4200780f8, 0xc420043e80, 0x8, 0x20, 0xc420043e80)
/mnt/d/go/src/github.com/boltdb/bolt/bucket.go:112 +0xde
github.com/boltdb/bolt.(*Tx).Bucket(0xc4200780e0, 0xc420043e80, 0x8, 0x20, 0x8)
/mnt/d/go/src/github.com/boltdb/bolt/tx.go:101 +0x4f
main.main.func2(0xc4200780e0, 0x4e5f08, 0xc4200780e0)
/mnt/d/main.go:28 +0x81
github.com/boltdb/bolt.(*DB).View(0xc420072000, 0x4e5f38, 0x0, 0x0)
/mnt/d/go/src/github.com/boltdb/bolt/db.go:629 +0x90
main.main()
/mnt/d/main.go:27 +0x10f
exit status 2
I expect no panics for this code 😃
- Strace of the failing command, if applicable: https://gist.github.com/vansante/14cd6e6b6806d10e41bda2bbf949aa24
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16
Looks like this issue in BoltDB cause to crashing docker:
I believe this is not a boltdb issue, but an issue with how WSL handles mmap calls from what I’ve observed.