Skip to content

internal/batchskl: checkptr: unsafe pointer conversion #667

@jbowens

Description

@jbowens

Go 1.14 adds a new checkptr compile flag which is enabled when running with -race. Running go test -race ./internal/batchskl w/ Go 1.14 produces:

fatal error: checkptr: unsafe pointer conversion

goroutine 36 [running]:
runtime.throw(0x184eb61, 0x23)
	/usr/local/Cellar/go/1.14/libexec/src/runtime/panic.go:1112 +0x72 fp=0xc00006caa0 sp=0xc00006ca70 pc=0x1073af2
runtime.checkptrAlignment(0xc000180b70, 0x1801a40, 0x1)
	/usr/local/Cellar/go/1.14/libexec/src/runtime/checkptr.go:18 +0xb7 fp=0xc00006cad0 sp=0xc00006caa0 pc=0x1045a97
github.com/cockroachdb/pebble/internal/batchskl.(*Skiplist).node(...)
	/Users/jbowens/go/src/github.com/cockroachdb/pebble/internal/batchskl/skl.go:292
github.com/cockroachdb/pebble/internal/batchskl.(*Skiplist).newNode(0xc0003af3b0, 0x1, 0x600000002, 0x6b65793100000000, 0x1)
	/Users/jbowens/go/src/github.com/cockroachdb/pebble/internal/batchskl/skl.go:265 +0x16c fp=0xc00006cb60 sp=0xc00006cad0 pc=0x1742a2c
github.com/cockroachdb/pebble/internal/batchskl.(*Skiplist).Add(0xc0003af3b0, 0x0, 0x4, 0x0)
	/Users/jbowens/go/src/github.com/cockroachdb/pebble/internal/batchskl/skl.go:233 +0x5fa fp=0xc00006cd88 sp=0xc00006cb60 pc=0x174202a
github.com/cockroachdb/pebble/internal/batchskl.TestBasic(0xc00014de60)
	/Users/jbowens/go/src/github.com/cockroachdb/pebble/internal/batchskl/skl_test.go:161 +0x151 fp=0xc00006ced0 sp=0xc00006cd88 pc=0x1745371
testing.tRunner(0xc00014de60, 0x18a6868)
	/usr/local/Cellar/go/1.14/libexec/src/testing/testing.go:992 +0x1ec fp=0xc00006cfd0 sp=0xc00006ced0 pc=0x11b613c
runtime.goexit()
	/usr/local/Cellar/go/1.14/libexec/src/runtime/asm_amd64.s:1373 +0x1 fp=0xc00006cfd8 sp=0xc00006cfd0 pc=0x10a7681
created by testing.(*T).Run
	/usr/local/Cellar/go/1.14/libexec/src/testing/testing.go:1043 +0x661

I think it's complaining because if we allocate a node at the end of the arena and that node has a low height in the skiplist, the bottom of the node struct will point into unallocated memory (rather than the typical allocated, but reserved for a different *node).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions