`lean` leaks
RalfJung opened this issue · comments
Ralf Jung commented
As discovered by Miri, the lean
variant of beef leaks memory. I verified that by adding this patch
diff --git a/src/generic.rs b/src/generic.rs
index add1a9b..9fa0981 100644
--- a/src/generic.rs
+++ b/src/generic.rs
@@ -170,6 +170,7 @@ where
#[inline]
fn drop(&mut self) {
if let Some(capacity) = self.capacity() {
+ panic!("dropping!");
unsafe { T::owned_from_parts::<U>(self.inner, capacity) };
}
}
and then running cargo test lean
. Clearly that should drop the contents and thus panic at some point, but it does not.
Maciej Hirsz commented
Oh dear me, when I was reimplementing this into generics I've made two separate mistakes that both separately cause this: 2e75601#diff-b722bb40412152063337bda6ba389775
line 23: MASK_HI
was always 0.
line 50: capacity was zeroed before bitshifted.