Skip to content

NewBoltStore seems to be causing a checkptr error when testing with race checker #45

@naskovik

Description

@naskovik

The full project is here: https://github.com/travisjeffery/proglog/tree/master/CoordinateWithConsensus or here: https://github.com/naskovik/distirbuted_services_with_go

This is a test function I wrote to isolate the error I was getting:

package isolation

import (
	"os"
	"path/filepath"
	"testing"

	raftboltdb "github.com/hashicorp/raft-boltdb"
	"github.com/stretchr/testify/require"
)

func TestStraddleIsolation(t *testing.T) {
	dataDir, err := os.MkdirTemp("", "straddle-test")
	require.NoError(t, err)
	_, err = raftboltdb.NewBoltStore(
		filepath.Join(dataDir, "raft.db"),
	)
	require.NoError(t, err)
}

And this is the result of running go test -race on this module:

go test -race ./internal/isolation

fatal error: checkptr: converted pointer straddles multiple allocations

goroutine 7 gp=0xc00015e8c0 m=0 mp=0xa63d60 [running]:
runtime.throw({0x8008dd?, 0x607901?})
	/usr/lib/go/src/runtime/panic.go:1096 +0x48 fp=0xc000067a58 sp=0xc000067a28 pc=0x4afb08
runtime.checkptrAlignment(0xa63d60?, 0x0?, 0x300000000067ad8?)
	/usr/lib/go/src/runtime/checkptr.go:26 +0x5b fp=0xc000067a78 sp=0xc000067a58 pc=0x44729b
github.com/boltdb/bolt.(*Bucket).write(0xc000067bb8)
	/home/nazar/go/pkg/mod/github.com/boltdb/[email protected]/bucket.go:626 +0x1f2 fp=0xc000067b08 sp=0xc000067a78 pc=0x609032
github.com/boltdb/bolt.(*Bucket).CreateBucket(0xc0000000f8, {0xa075c4, 0x4, 0x4})
	/home/nazar/go/pkg/mod/github.com/boltdb/[email protected]/bucket.go:188 +0x43c fp=0xc000067cf8 sp=0xc000067b08 pc=0x60795c
github.com/boltdb/bolt.(*Bucket).CreateBucketIfNotExists(0xc0000000f8, {0xa075c4, 0x4, 0x4})
	/home/nazar/go/pkg/mod/github.com/boltdb/[email protected]/bucket.go:206 +0x49 fp=0xc000067d48 sp=0xc000067cf8 pc=0x607be9
github.com/boltdb/bolt.(*Tx).CreateBucketIfNotExists(...)
	/home/nazar/go/pkg/mod/github.com/boltdb/[email protected]/tx.go:115
github.com/hashicorp/raft-boltdb.(*BoltStore).initialize(0xc000010588)
	/home/nazar/go/pkg/mod/github.com/hashicorp/[email protected]/bolt_store.go:108 +0x107 fp=0xc000067de8 sp=0xc000067d48 pc=0x7024c7
github.com/hashicorp/raft-boltdb.New({{0xc000020660, 0x24}, 0x0, 0x0})
	/home/nazar/go/pkg/mod/github.com/hashicorp/[email protected]/bolt_store.go:87 +0x194 fp=0xc000067e68 sp=0xc000067de8 pc=0x702314
github.com/hashicorp/raft-boltdb.NewBoltStore(...)
	/home/nazar/go/pkg/mod/github.com/hashicorp/[email protected]/bolt_store.go:66
github.com/naskovik/proglog/internal/isolation.TestStraddleIsolation(0xc00015e700)
	/home/nazar/projects/proglog/internal/isolation/straddle_test.go:15 +0xc5 fp=0xc000067ee0 sp=0xc000067e68 pc=0x707d85
testing.tRunner(0xc00015e700, 0x807ed8)
	/usr/lib/go/src/testing/testing.go:1792 +0x226 fp=0xc000067fb0 sp=0xc000067ee0 pc=0x586186
testing.(*T).Run.gowrap1()
	/usr/lib/go/src/testing/testing.go:1851 +0x45 fp=0xc000067fe0 sp=0xc000067fb0 pc=0x587ee5
runtime.goexit({})
	/usr/lib/go/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000067fe8 sp=0xc000067fe0 pc=0x4b6c61
created by testing.(*T).Run in goroutine 1
	/usr/lib/go/src/testing/testing.go:1851 +0x8f3

This is my go.mod


go 1.23.4

require (
	github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
	github.com/hashicorp/raft v1.7.2
	github.com/hashicorp/serf v0.10.2
	github.com/soheilhy/cmux v0.1.5
	github.com/stretchr/testify v1.10.0
	github.com/travisjeffery/go-dynaport v1.0.0
	github.com/tysonmote/gommap v0.0.3
	go.opencensus.io v0.24.0
	go.uber.org/zap v1.27.0
	google.golang.org/grpc v1.70.0
	google.golang.org/protobuf v1.36.3
)

require (
	github.com/armon/go-metrics v0.4.1 // indirect
	github.com/boltdb/bolt v1.3.1 // indirect
	github.com/fatih/color v1.13.0 // indirect
	github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
	github.com/golang/protobuf v1.5.4 // indirect
	github.com/google/btree v1.1.2 // indirect
	github.com/hashicorp/errwrap v1.1.0 // indirect
	github.com/hashicorp/go-hclog v1.6.2 // indirect
	github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
	github.com/hashicorp/go-metrics v0.5.4 // indirect
	github.com/hashicorp/go-msgpack v0.5.5 // indirect
	github.com/hashicorp/go-msgpack/v2 v2.1.2 // indirect
	github.com/hashicorp/go-multierror v1.1.1 // indirect
	github.com/hashicorp/go-sockaddr v1.0.5 // indirect
	github.com/hashicorp/golang-lru v1.0.2 // indirect
	github.com/hashicorp/memberlist v0.5.2 // indirect
	github.com/hashicorp/raft-boltdb v0.0.0-20250225060035-8f7048cdfa53 // indirect <== RAFT-BOLTDB HERE
	github.com/mattn/go-colorable v0.1.12 // indirect
	github.com/mattn/go-isatty v0.0.14 // indirect
	github.com/miekg/dns v1.1.56 // indirect
	github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
	go.uber.org/multierr v1.11.0 // indirect
	golang.org/x/mod v0.17.0 // indirect
	golang.org/x/sync v0.10.0 // indirect
	golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
)

require (
	github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
	github.com/casbin/casbin/v2 v2.103.0
	github.com/casbin/govaluate v1.3.0 // indirect
)

require (
	github.com/davecgh/go-spew v1.1.1 // indirect
	github.com/pmezard/go-difflib v1.0.0 // indirect
	golang.org/x/net v0.32.0 // indirect
	golang.org/x/sys v0.28.0 // indirect
	golang.org/x/text v0.21.0 // indirect
	google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a
	gopkg.in/yaml.v3 v3.0.1 // indirect
)

Is it me doing something wrong?

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