[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#8406) LMDB: Assertion 'mc->mc_flags & C_INITIALIZED' with MDB_NEXT after mdb_cursor_del



Full_Name: Argyrios Kyrtzidis
Version: LMDB master
OS: OSX
URL: 
Submission from: (NULL) (2601:646:8900:3c89:b9af:5cb2:7292:8835)


With latest lmdb source (github mirror:
8fff90db7ed1e650395f39f9e8b22673aa74aa2b), there is an assertion hit when
deleting the cursor and then doing mdb_cursor_get(MDB_NEXT) and 'entering'
DUPSORT items.
To demonstrate see below diff which modifies mtest3.c. When run you see this:

mdb.c:6424: Assertion 'mc->mc_flags & C_INITIALIZED' failed in
mdb_cursor_next()

====
diff --git a/libraries/liblmdb/mtest3.c b/libraries/liblmdb/mtest3.c
dedex 73ee6e2..a9eb011 100644
--- a/libraries/liblmdb/mtest3.c
+++ b/libraries/liblmdb/mtest3.c
@@ -62,6 +62,19 @@ int main(int argc,char * argv[])
 	data.mv_size = sizeof(sval);
 	data.mv_data = sval;
 
+	memset(sval, sizeof(sval), 0);
+	memset(kval, sizeof(kval), 0);
+	kval[0] = 1;
+	mdb_put(txn, dbi, &key, &data, 0);
+	kval[0] = 2;
+	mdb_put(txn, dbi, &key, &data, 0);
+	sval[0] = 1;
+	mdb_put(txn, dbi, &key, &data, 0);
+	E(mdb_cursor_open(txn, dbi, &cursor));
+	E(mdb_cursor_get(cursor, &key, &data, MDB_NEXT));
+	E(mdb_cursor_del(cursor, 0));
+	E(mdb_cursor_get(cursor, &key, &data, MDB_NEXT)); // Assertion hit.
+
 	printf("Adding %d values\n", count);
 	for (i=0;i<count;i++) {
 		if (!(i & 0x0f))