Skip to content

Problem: a crash on dropping a transaction after env #23

Description

@yrashk
    #[test]
    fn lmdb_crash() {
        use std::sync::Arc;
        let dir = tempfile::tempdir().unwrap();
        let env = Arc::new(unsafe {
            let mut builder = lmdb_zero::EnvBuilder::new().unwrap();
            builder.set_maxdbs(10).unwrap();
            builder.open(dir.path().to_str().unwrap(), lmdb_zero::open::NOTLS, 0o600).unwrap()
        });

        let txn = lmdb_zero::ReadTransaction::new(env.clone()).unwrap();

        drop(env);
        // CRASHES HERE
        drop(txn);
    }

Basically, by using an Arc-wrapped env and creating a read txn, then dropping the environment and trying to drop txn, it segfaults with:

mdb_txn_end (txn=0x7fffd03024e0, mode=<optimized out>) at /home/yrashk/.cargo/git/checkouts/lmdb-rs-d312082a7acf8730/ad09768/liblmdb-sys/mdb/libraries/liblmdb/mdb.c:3312
3312				txn->mt_u.reader->mr_txnid = (txnid_t)-1;
(gdb) bt
#0  mdb_txn_end (txn=0x7fffd03024e0, mode=<optimized out>) at /home/yrashk/.cargo/git/checkouts/lmdb-rs-d312082a7acf8730/ad09768/liblmdb-sys/mdb/libraries/liblmdb/mdb.c:3312
#1  0x0000555555a95a65 in <lmdb_zero::tx::TxHandle as core::ops::drop::Drop>::drop (self=0x7ffff5a0c600) at /home/yrashk/.cargo/registry/src/github.com-1ecc6299db9ec823/lmdb-zero-0.4.4/src/tx.rs:255

Is this an expected behavior in this set up or is this indeed an issue?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions