rust-rocksdb / rust-rocksdb/rust-rocksdb
rocksdb on std::thread can segfault if not shutdown gracefully
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.2k
- Forks
- 874
- PR merge metrics
- No merged PRs in 30d
Description
On my m1 mac, I get a segfault when running cargo test under certain conditions. I was unable to minimize the test case, buts its fairly basic: https://github.com/guswynn/materialize/commit/f1b6a71cb70310a596be60ace6f658b08c77df7b
Is this just a rocksdb bug?
Backtrace of the segfault:
Core file '/cores/core.77535' (arm64) was loaded.
(lldb) bt
* thread #2, stop reason = ESR_EC_DABORT_EL0 (fault address: 0x17)
* frame #0: 0x00000001025939f8 mz_rocksdb-892284438b8c51ce`std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__is_long[abi:v15006](this=Summary Unavailable) const at string:1499:33
frame #1: 0x00000001025856d8 mz_rocksdb-892284438b8c51ce`std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::size[abi:v15006](this=Summary Unavailable) const at string:968:17
frame #2: 0x00000001025901f0 mz_rocksdb-892284438b8c51ce`bool std::__1::operator==[abi:v15006]<char, std::__1::char_traits<char>, std::__1::allocator<char> >(__lhs=Summary Unavailable, __rhs="id") at string:4199:28
frame #3: 0x0000000102a6a4f0 mz_rocksdb-892284438b8c51ce`rocksdb::Customizable::GetOption(this=0x0000000102ed95b0, config_options=0x000000016e09d320, opt_name=Summary Unavailable, value="") const at customizable.cc:42:16
frame #4: 0x00000001025a80b0 mz_rocksdb-892284438b8c51ce`rocksdb::ColumnFamilyData::~ColumnFamilyData(this=0x000000013b815c00) at column_family.cc:708:31
frame #5: 0x00000001025a8318 mz_rocksdb-892284438b8c51ce`rocksdb::ColumnFamilyData::~ColumnFamilyData(this=0x000000013b815c00) at column_family.cc:663:39
frame #6: 0x00000001025a3ee8 mz_rocksdb-892284438b8c51ce`rocksdb::ColumnFamilyData::UnrefAndTryDelete(this=0x000000013b815c00) at column_family.cc:724:5
frame #7: 0x00000001025a5a04 mz_rocksdb-892284438b8c51ce`rocksdb::SuperVersion::Cleanup(this=0x000000011b604080) at column_family.cc:483:8
frame #8: 0x00000001025a3f68 mz_rocksdb-892284438b8c51ce`rocksdb::ColumnFamilyData::UnrefAndTryDelete(this=0x000000013b815c00) at column_family.cc:739:11
frame #9: 0x00000001025ab928 mz_rocksdb-892284438b8c51ce`rocksdb::ColumnFamilySet::~ColumnFamilySet(this=0x000000013d005000) at column_family.cc:1559:21
frame #10: 0x00000001025aba5c mz_rocksdb-892284438b8c51ce`rocksdb::ColumnFamilySet::~ColumnFamilySet(this=0x000000013d005000) at column_family.cc:1554:37
frame #11: 0x00000001028f7510 mz_rocksdb-892284438b8c51ce`std::__1::default_delete<rocksdb::ColumnFamilySet>::operator(this=0x000000013d004dc8, __ptr=0x000000013d005000)[abi:v15006](rocksdb::ColumnFamilySet*) const at unique_ptr.h:48:5
frame #12: 0x00000001028a7b9c mz_rocksdb-892284438b8c51ce`std::__1::unique_ptr<rocksdb::ColumnFamilySet, std::__1::default_delete<rocksdb::ColumnFamilySet> >::reset[abi:v15006](this=0x000000013d004dc8, __p=0x0000000000000000) at unique_ptr.h:305:7
frame #13: 0x00000001028a797c mz_rocksdb-892284438b8c51ce`rocksdb::VersionSet::~VersionSet(this=0x000000013d004da0) at version_set.cc:4728:22
frame #14: 0x00000001028a7cf8 mz_rocksdb-892284438b8c51ce`rocksdb::VersionSet::~VersionSet(this=0x000000013d004da0) at version_set.cc:4725:27
frame #15: 0x00000001028a7d24 mz_rocksdb-892284438b8c51ce`rocksdb::VersionSet::~VersionSet(this=0x000000013d004da0) at version_set.cc:4725:27
frame #16: 0x0000000102757318 mz_rocksdb-892284438b8c51ce`std::__1::default_delete<rocksdb::VersionSet>::operator(this=0x000000013c809c50, __ptr=0x000000013d004da0)[abi:v15006](rocksdb::VersionSet*) const at unique_ptr.h:48:5
frame #17: 0x000000010273d4ac mz_rocksdb-892284438b8c51ce`std::__1::unique_ptr<rocksdb::VersionSet, std::__1::default_delete<rocksdb::VersionSet> >::reset[abi:v15006](this=0x000000013c809c50, __p=0x0000000000000000) at unique_ptr.h:305:7
frame #18: 0x000000010265265c mz_rocksdb-892284438b8c51ce`rocksdb::DBImpl::CloseHelper(this=0x000000013c809c00) at db_impl.cc:697:13
frame #19: 0x0000000102653278 mz_rocksdb-892284438b8c51ce`rocksdb::DBImpl::CloseImpl(this=0x000000013c809c00) at db_impl.cc:743:37
frame #20: 0x0000000102653340 mz_rocksdb-892284438b8c51ce`rocksdb::DBImpl::~DBImpl(this=0x000000013c809c00) at db_impl.cc:761:21
frame #21: 0x0000000102653718 mz_rocksdb-892284438b8c51ce`rocksdb::DBImpl::~DBImpl(this=0x000000013c809c00) at db_impl.cc:745:19
frame #22: 0x0000000102653744 mz_rocksdb-892284438b8c51ce`rocksdb::DBImpl::~DBImpl(this=0x000000013c809c00) at db_impl.cc:745:19
frame #23: 0x0000000102584498 mz_rocksdb-892284438b8c51ce`::rocksdb_close(db=0x00006000002980c0) at c.cc:852:3
frame #24: 0x0000000102539904 mz_rocksdb-892284438b8c51ce`_$LT$rocksdb..db..DBWithThreadModeInner$u20$as$u20$core..ops..drop..Drop$GT$::drop::h6a1e5c361288c76d(self=0x000000016e09e048) at db.rs:290:13
frame #25: 0x00000001023a429c mz_rocksdb-892284438b8c51ce`core::ptr::drop_in_place$LT$rocksdb..db..DBWithThreadModeInner$GT$::hbaf82072699e8ce4((null)=0x000000016e09e048) at mod.rs:490:1
frame #26: 0x00000001023a1ed0 mz_rocksdb-892284438b8c51ce`core::ptr::drop_in_place$LT$rocksdb..db..DBCommon$LT$rocksdb..db..SingleThreaded$C$rocksdb..db..DBWithThreadModeInner$GT$$GT$::hab4f5ba128d89c0c((null)=0x000000016e09e048) at mod.rs:490:1
frame #27: 0x00000001023a0980 mz_rocksdb-892284438b8c51ce`core::mem::drop::h338d7ff40710fcd2(_x=<unavailable>) at mod.rs:980:24
frame #28: 0x00000001023b6fd4 mz_rocksdb-892284438b8c51ce`mz_rocksdb::RocksDBInstance$LT$K$C$V$GT$::new::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h26daf6403310d934 at lib.rs:184:21
frame #29: 0x00000001023b203c mz_rocksdb-892284438b8c51ce`std::sys_common::backtrace::__rust_begin_short_backtrace::h70552df3e5644218(f=<unavailable>) at backtrace.rs:121:18
frame #30: 0x0000000102390308 mz_rocksdb-892284438b8c51ce`std::thread::Builder::spawn_unchecked_::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h5a31e0b6c0205bda at mod.rs:558:17
frame #31: 0x000000010239f690 mz_rocksdb-892284438b8c51ce`_$LT$core..panic..unwind_safe..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h42cc6a45b1f599c2(self=<unavailable>, _args=<unavailable>) at unwind_safe.rs:271:9
frame #32: 0x00000001023c35ac mz_rocksdb-892284438b8c51ce`std::panicking::try::do_call::h13ca656150c6b4f2(data=" \x80\t") at panicking.rs:483:40
frame #33: 0x00000001023c5430 mz_rocksdb-892284438b8c51ce`__rust_try + 32
frame #34: 0x00000001023c3300 mz_rocksdb-892284438b8c51ce`std::panicking::try::hb4ac7441cb2525d1(f=<unavailable>) at panicking.rs:447:19
frame #35: 0x00000001023c2af0 mz_rocksdb-892284438b8c51ce`std::panic::catch_unwind::h313606d057239ca5(f=<unavailable>) at panic.rs:140:14
frame #36: 0x0000000102390174 mz_rocksdb-892284438b8c51ce`std::thread::Builder::spawn_unchecked_::_$u7b$$u7b$closure$u7d$$u7d$::hf85f3de5cb2f699e at mod.rs:557:30
frame #37: 0x00000001023a1604 mz_rocksdb-892284438b8c51ce`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h4f99a5fcc1cfb828((null)=0x00006000023940f0, (null)=<unavailable>) at function.rs:250:5
frame #38: 0x0000000102ce6bb0 mz_rocksdb-892284438b8c51ce`std::sys::unix::thread::Thread::new::thread_start::h7c145656763309f3 [inlined] _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::h834161c0bc079953 at boxed.rs:1988:9 [opt]
frame #39: 0x0000000102ce6ba4 mz_rocksdb-892284438b8c51ce`std::sys::unix::thread::Thread::new::thread_start::h7c145656763309f3 [inlined] _$LT$alloc..boxed..Box$LT$F$C$A$GT$$u20$as$u20$core..ops..function..FnOnce$LT$Args$GT$$GT$::call_once::h551d17f69af224a8 at boxed.rs:1988:9 [opt]
frame #40: 0x0000000102ce6ba0 mz_rocksdb-892284438b8c51ce`std::sys::unix::thread::Thread::new::thread_start::h7c145656763309f3 at thread.rs:108:17 [opt]
frame #41: 0x00000001aca7bfa8 libsystem_pthread.dylib`_pthread_start + 148
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducer commit linked in the issue and run the relevant cargo test on macOS. Trace the thread closure in lib.rs:184 through the DB drop implementation in db.rs:290 and compare it with the backtrace's rocksdb_close path. Done means reproducing the shutdown crash, identifying its cause, and adding a regression test that verifies graceful shutdown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100