Open bh1xuw opened 7 years ago
NOTE:
NO leaks if you don't use customized comparator or compaction filter.
rocks-sys/rocks/options.cc:
rocks_cfoptions_set_comparator_by_trait rocks_cfoptions_set_compaction_filter_by_trait
Both leak 16 bytes when used in Option.set_xxx. (== sizeof A Rust Trait Object)
Option.set_xxx
Reason:
In C++, these 2 options are static pointers, instead of std::shared_ptr. (They are to be used across many CFs.)
std::shared_ptr
In Rust, use Box<Box<T>> as *mut Box<T> (1 pointer size = sizeof void*). Box::into_raw used without Box::from_raw.
Box<Box<T>>
*mut Box<T>
void*
Box::into_raw
Box::from_raw
Possible Solution:
Attach Comparator & CompactionFilter lifetime to DB or sth.
CMD:
RUSTFLAGS="-Z sanitizer=leak" cargo +nightly test --target x86_64-unknown-linux-gnu 2>&1 | asan_symbolize -d
NOTE:
rocks-sys/rocks/options.cc:
Both leak 16 bytes when used in
Option.set_xxx
. (== sizeof A Rust Trait Object)Reason:
In C++, these 2 options are static pointers, instead of
std::shared_ptr
. (They are to be used across many CFs.)In Rust, use
Box<Box<T>>
as*mut Box<T>
(1 pointer size = sizeofvoid*
).Box::into_raw
used withoutBox::from_raw
.Possible Solution:
Attach Comparator & CompactionFilter lifetime to DB or sth.