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

[BUG] LruEntry uninitialized, which is invalid #2

Closed
dollarkillerx opened this issue May 7, 2021 · 2 comments
Closed

[BUG] LruEntry uninitialized, which is invalid #2

dollarkillerx opened this issue May 7, 2021 · 2 comments

Comments

@dollarkillerx
Copy link

dollarkillerx commented May 7, 2021

  • bitcask master
  • cargo 1.50.0 (f04e7fab7 2021-02-04)
  • rustc 1.50.0 (cb75ad5db 2021-02-10)

run demo:

use bitcask;
use bytesize::ByteSize;

fn main() {
    let options = bitcask::Options {
        base_dir: std::path::PathBuf::from("./db1"),
        data_file_limit: ByteSize::mb(10).as_u64(),
    };

    let db = bitcask::new(options);
    if let Err(err_msg) = db {
        println!("{}", err_msg);
        std::process::exit(1);
    }
    let mut db = db.unwrap();

    for n in 0..1000 {
        let name = format!("Peter Nr. {}", n);
        let key = format!("name:{}", n);

        db.write(key.as_bytes(), name.as_bytes()).unwrap();
    }

    db.close().unwrap();
}

error report:

thread 'main' panicked at 'attempted to leave type `database::lru::LruEntry<u128, datafile::DataFile>` uninitialized, which is invalid', /home/xx/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/mod.rs:659:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/cb75ad5db02783e8b0222fee363c5f63f7e2cf5b/library/core/src/panicking.rs:50:5
   3: core::mem::uninitialized
             at /home/xx/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/mod.rs:659:9
   4: lru::LruCache<K,V,S>::construct
             at /home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/lru-0.1.17/src/lib.rs:216:51
   5: lru::LruCache<K,V>::new
             at /home/xx/.cargo/registry/src/github.com-1ecc6299db9ec823/lru-0.1.17/src/lib.rs:173:9
   6: bitcask::database::new
             at /home/xx/.cargo/git/checkouts/bitcask-ef3cb47bcd03a3bd/f218892/src/database.rs:75:27
   7: bitcask_rs::main
             at ./src/main.rs:10:14
   8: core::ops::function::FnOnce::call_once
             at /home/xx/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@dragonquest
Copy link
Owner

@dollarkillerx Sorry for getting back to you late, and THANK YOU very much for reporting this error. I will have a look when I have some free time. Feel free to send a pull request.

@papdpcpd
Copy link

papdpcpd commented Jun 9, 2021

this problem from lru :https://crates.io/crates/lru
use the latest version to fix this problem

....
# lru = "0.1.17"
lru = "0.6.5"
....

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

3 participants