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

lean leaks #12

Closed
RalfJung opened this issue Mar 18, 2020 · 1 comment · Fixed by #14
Closed

lean leaks #12

RalfJung opened this issue Mar 18, 2020 · 1 comment · Fixed by #14

Comments

@RalfJung
Copy link
Contributor

RalfJung commented Mar 18, 2020

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.

@maciejhirsz
Copy link
Owner

maciejhirsz commented Mar 18, 2020

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.

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

Successfully merging a pull request may close this issue.

2 participants