Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It can cause panic while running test data with some special #92

Open
absolute8511 opened this issue Feb 25, 2021 · 1 comment
Open

Comments

@absolute8511
Copy link

absolute8511 commented Feb 25, 2021

I found the test code below can cause the panic of DB, is any wrong with the test code?

type ritem struct {
	Key   string
	Value []byte
}
	base := []byte{1, 0, 1, 0}
	key := append([]byte{}, base...)
	minKey := []byte{1, 0, 1}

	schema := &memdb.DBSchema{
		Tables: map[string]*memdb.TableSchema{
			"0": &memdb.TableSchema{
				Name: "0",
				Indexes: map[string]*memdb.IndexSchema{
					"id": &memdb.IndexSchema{
						Name:    "id",
						Unique:  true,
						Indexer: &memdb.StringFieldIndex{Field: "Key"},
					},
				},
			},
		},
	}
	mdb, err := memdb.NewMemDB(schema)
	assert.Nil(t, err)

	txn := mdb.Txn(true)
	txn.Insert("0", &ritem{Key: string(key), Value: []byte("1")})
	txn.Insert("0", &ritem{Key: string(append(key, byte(1))), Value: []byte("1")})
	txn.Commit()

	txn = mdb.Txn(false)
	defer txn.Abort()
	resIter, err := txn.LowerBound("0", "id", string(minKey))  // panic happened here
	assert.Nil(t, err)
@absolute8511
Copy link
Author

It is related to the issue in hashicorp/go-immutable-radix#28
and could be fixed by the pr hashicorp/go-immutable-radix#35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant