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

TransactionDB open_default panic #881

Open
fansehep opened this issue Apr 26, 2024 · 6 comments
Open

TransactionDB open_default panic #881

fansehep opened this issue Apr 26, 2024 · 6 comments

Comments

@fansehep
Copy link

This demo in my laptop, it will panic.

use rocksdb::TransactionDB;

fn main() {
    let _db: TransactionDB = rocksdb::TransactionDB::open_default("./rocks_data").unwrap();
    
    println!("Hello, world!");
}

output:

thread 'main' panicked at library/core/src/panicking.rs:220:5:
unsafe precondition(s) violated: ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null and the specified memory ranges do not overlap
stack backtrace:
   0: rust_begin_unwind
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_nounwind_fmt::runtime
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe/library/core/src/panicking.rs:110:18
   2: core::panicking::panic_nounwind_fmt
             at /rustc/3a36386dc1075018dc7ca2640a2656adb31a61fe/library/core/src/panicking.rs:120:5
   ...

I'm confused about this.

@fansehep
Copy link
Author

I switch the rustc to stable, it will be ok. :(

@peacess
Copy link

peacess commented May 8, 2024

i have the same case, just call open_default, and then panic.

std::ptr::copy_nonoverlapping(ptr, vec.as_mut_ptr(), cnt); the ptr parameter is NULL, so it will panic

@ravlio
Copy link

ravlio commented May 21, 2024

Same, but only during tests

@miladamery
Copy link

miladamery commented May 26, 2024

I Have the same issue

unsafe precondition(s) violated: ptr::copy_nonoverlapping requires that both pointer arguments 

are aligned and non-null and the specified memory ranges do not overlap

any idea why this happens?

@pragmaxim
Copy link

pragmaxim commented May 26, 2024

It only happens with

rustc 1.78.0 AND 1.80.0-nightly

but not

rustc 1.75.0

Testing with :

rocksdb = "0.22.0" AND 0.21.0
let mut opts = Options::default();
opts.create_if_missing(true);
let txn_db_opts = TransactionDBOptions::default();
let db = TransactionDB::open(&opts, &txn_db_opts, db_path).unwrap();
   0: rust_begin_unwind                                                                                                                                                                                                                        
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5                                                                                                                                             
   1: core::panicking::panic_nounwind_fmt::runtime                                                                                                                                                                                             
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:110:18                                                                                                                                           
   2: core::panicking::panic_nounwind_fmt                                                                                                                                                                                                      
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:123:9                                                                                                                                            
   3: core::panicking::panic_nounwind                                                                                                                                                                                                          
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:156:5
   4: core::intrinsics::copy_nonoverlapping::precondition_check
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/intrinsics.rs:2799:21
   5: core::intrinsics::copy_nonoverlapping
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/intrinsics.rs:2969:5
   6: rocksdb::transactions::transaction_db::TransactionDB<T>::open_cf_descriptors_internal
             at /home/lisak/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rocksdb-0.22.0/src/transactions/transaction_db.rs:303:13
   7: rocksdb::transactions::transaction_db::TransactionDB<T>::open_cf
             at /home/lisak/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rocksdb-0.22.0/src/transactions/transaction_db.rs:200:9
   8: rocksdb::transactions::transaction_db::TransactionDB<T>::open
             at /home/lisak/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rocksdb-0.22.0/src/transactions/transaction_db.rs:179:9
   9: index_btc::merkle::AddressIndexer::new

@mpartel
Copy link

mpartel commented Jun 2, 2024

Workaround:

rocksdb = { git = "https://github.com/rust-rocksdb/rust-rocksdb", rev = "1cf906dc4087f06631820f13855e6b27bd21b972" }

The other commits between 0.22.0 and that one are very minor.

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

6 participants