hyc(a)symas.com wrote on 2019-06-19 09:55:
> Maybe. For testing purposes you could try something like this
> diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c
> index 692feaa38b..e41f3bc36a 100644
> --- a/libraries/liblmdb/mdb.c
> +++ b/libraries/liblmdb/mdb.c
> @@ -7620,7 +7620,8 @@ mdb_cursor_init(MDB_cursor *mc, MDB_txn *txn, MDB_dbi dbi, MDB_xcursor *mx)
> mc->mc_xcursor = NULL;
> }
> if (*mc->mc_dbflag & DB_STALE) {
> - mdb_page_search(mc, NULL, MDB_PS_ROOTONLY);
> + int rc = mdb_page_search(mc, NULL, MDB_PS_ROOTONLY);
> + mdb_cassert(mc, !rc);
> }
> }
I'm unsure if it's related, but with this change to mdb.c, the following
test program (which resembles Firefox's usage) asserts in
mdb_cursor_init because rc is MDB_NOTFOUND.
#include <stdio.h>
#include <stdlib.h>
#include "lmdb.h"
#define E(expr) CHECK((rc = (expr)) == MDB_SUCCESS, #expr)
#define CHECK(test, msg) ((test) ? (void)0 : ((void)fprintf(stderr, \
"%s:%d: %s: %s\n", __FILE__, __LINE__, msg, mdb_strerror(rc)),
abort()))
int main(int argc,char * argv[])
{
int rc;
MDB_env *env;
MDB_dbi dbi;
MDB_val key, data;
MDB_txn *txn;
char sval[] = "foo";
char dval[] = "bar";
E(mdb_env_create(&env));
E(mdb_env_set_maxdbs(env, 2));
E(mdb_env_open(env, "./mytestdb", 0, 0664));
E(mdb_txn_begin(env, NULL, 0, &txn));
E(mdb_dbi_open(txn, "subdb", MDB_CREATE, &dbi));
E(mdb_txn_commit(txn));
key.mv_size = 3;
key.mv_data = sval;
data.mv_size = 3;
data.mv_data = dval;
E(mdb_txn_begin(env, NULL, 0, &txn));
E(mdb_put(txn, dbi, &key, &data, 0));
E(mdb_txn_commit(txn));
mdb_dbi_close(env, dbi);
mdb_env_close(env);
return 0;
}
Without the change to mdb.c, however, the program appears to work correctly.
-myk