|
|
@ -62,6 +62,9 @@ mod transaction; |
|
|
|
#[cfg(test)] |
|
|
|
#[cfg(test)] |
|
|
|
mod test_utils { |
|
|
|
mod test_utils { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern crate byteorder; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use self::byteorder::{ByteOrder, LittleEndian}; |
|
|
|
use tempdir::TempDir; |
|
|
|
use tempdir::TempDir; |
|
|
|
|
|
|
|
|
|
|
|
use super::*; |
|
|
|
use super::*; |
|
|
@ -88,4 +91,33 @@ mod test_utils { |
|
|
|
} |
|
|
|
} |
|
|
|
(dir, env) |
|
|
|
(dir, env) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Regression test for https://github.com/danburkert/lmdb-rs/issues/21.
|
|
|
|
|
|
|
|
/// This test reliably segfaults when run against lmbdb compiled with opt level -O3 and newer
|
|
|
|
|
|
|
|
/// GCC compilers.
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
|
|
|
fn issue_21_regression() { |
|
|
|
|
|
|
|
const HEIGHT_KEY: [u8; 1] = [0]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let dir = TempDir::new("test").unwrap(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let env = { |
|
|
|
|
|
|
|
let mut builder = Environment::new(); |
|
|
|
|
|
|
|
builder.set_max_dbs(2); |
|
|
|
|
|
|
|
builder.set_map_size(1_000_000); |
|
|
|
|
|
|
|
builder.open(dir.path()).expect("open lmdb env") |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
let index = env.create_db(None, DUP_SORT).expect("open index db"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for height in 0..1000 { |
|
|
|
|
|
|
|
let mut value = [0u8; 8]; |
|
|
|
|
|
|
|
LittleEndian::write_u64(&mut value, height); |
|
|
|
|
|
|
|
let mut tx = env.begin_rw_txn().expect("begin_rw_txn"); |
|
|
|
|
|
|
|
tx.put(index, |
|
|
|
|
|
|
|
&HEIGHT_KEY, |
|
|
|
|
|
|
|
&value, |
|
|
|
|
|
|
|
WriteFlags::empty()).expect("tx.put"); |
|
|
|
|
|
|
|
tx.commit().expect("ts.commit") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|