-
Notifications
You must be signed in to change notification settings - Fork 20
Closed
Description
When removing all nodes from a Graph and then adding a node again a nil pointer dereference error occurs:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x4964e9]
goroutine 1 [running]:
github.com/coder/hnsw.(*Graph[...]).Dims(...)
/home/schuwi/go/pkg/mod/github.com/coder/hnsw@v0.6.1/graph.go:320
github.com/coder/hnsw.(*Graph[...]).assertDims(0x46892f?, {0x565404?, 0x1?, 0xc0001281b0})
/home/schuwi/go/pkg/mod/github.com/coder/hnsw@v0.6.1/graph.go:308 +0xa9
github.com/coder/hnsw.(*Graph[...]).Add(0x4e5ba0, {0xc000120f20, 0xc000062700?, 0x466b39?})
/home/schuwi/go/pkg/mod/github.com/coder/hnsw@v0.6.1/graph.go:334 +0x9c
main.main()
/tmp/go_hnsw_bug/main.go:18 +0x139
exit status 2
Minimum reproducible example:
package main
import (
"github.com/coder/hnsw"
)
var vec = []float32{1}
func main() {
g := hnsw.NewGraph[int]()
g.Add(hnsw.MakeNode(1, vec))
g.Delete(1)
// This call will fail on a nil pointer dereference
g.Add(hnsw.MakeNode(1, vec))
}
Metadata
Metadata
Assignees
Labels
No labels