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

AtomicOption should run Box::drop on drop. #142

Closed
quadrupleslap opened this issue Jun 9, 2017 · 2 comments
Closed

AtomicOption should run Box::drop on drop. #142

quadrupleslap opened this issue Jun 9, 2017 · 2 comments

Comments

@quadrupleslap
Copy link

Right now it's leaking memory and not running destructors. This is necessary:

impl<T> Drop for AtomicOption<T> {
    fn drop(&mut self) {
        let inner = self.inner.load(Ordering::SeqCst);
        if !inner.is_null() {
            unsafe { Box::from_raw(inner); }
        }
    }
}

Playground: https://is.gd/FUK0pr

@spacejam
Copy link
Contributor

just hit this while sanitizing for leaks...

spacejam added a commit to spacejam/crossbeam that referenced this issue Aug 23, 2017
@spacejam
Copy link
Contributor

mostly copied your code but SeqCst -> Relaxed because drop shouldn't get reordered before another thread's access.

#153

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants