segmentation violation
showsa opened this issue · 5 comments
SIGSEGV: segmentation violation
PC=0x45fc7d6
signal arrived during cgo execution
github.com/jmhodges/levigo._Cfunc_leveldb_iter_seek(0x0, 0xc2000abed0, 0x8)
github.com/jmhodges/levigo/_obj/_cgo_defun.c:231 +0x2f
github.com/jmhodges/levigo.(*Iterator).Seek(0xc2000008e8, 0xc2000abed0, 0x8, 0xe)
github.com/jmhodges/levigo/_obj/batch.cgo1.go:579 +0x42
...
$ go version
go version go1.1 darwin/amd64
code
cache := levigo.NewLRUCache(1 << 24) // 16MB
options := levigo.NewOptions()
//options.SetComparator(cmp)
options.SetCache(cache)
options.SetParanoidChecks(true)
options.SetInfoLog(nil)
options.SetWriteBufferSize(1 << 20) // 1MB
options.SetMaxOpenFiles(1023)
options.SetBlockSize(1 << 15) // 32KB
options.SetCompression(1) // snappy compression, 0 == no compression
options.SetCreateIfMissing(true)
levelDb, err := levigo.Open("./store", options)
if err != nil {
panic(err)
}
roptions := levigo.NewReadOptions()
//roptions.SetVerifyChecksums(true)
roptions.SetFillCache(false)
defer roptions.Close()
iter :=levelDb.NewIterator(roptions)
iter.Close()
target := append("t_user", uint8(1))
iter.Seek(target) // <== segmentation violation
You're ignoring the error from levigo.Open. I'm closing this ticket. Reopen if you see the problem after you've handled that error.
levelDb, err := levigo.Open("./store", options)
if err != nil {
panic(err)
}
and no problem to put key/value pairs.
You close the iterator before you use it. I'm not sure what you expect to happen.
missed "defer"
Sorry for that.
No problem! Happens.