bh1xuw / rust-rocks

Make RocksDB really rocks! The Rust style API.
Apache License 2.0
46 stars 7 forks source link

Memory Leaks #3

Open bh1xuw opened 7 years ago

bh1xuw commented 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)

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 = sizeof void*). Box::into_raw used without Box::from_raw.

Possible Solution:

Attach Comparator & CompactionFilter lifetime to DB or sth.

bh1xuw commented 7 years ago

CMD:

RUSTFLAGS="-Z sanitizer=leak" cargo +nightly test --target x86_64-unknown-linux-gnu  2>&1 | asan_symbolize -d