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

cordyceps: List doesn't impl Drop #165

Closed
jamesmunns opened this issue May 25, 2022 · 1 comment
Closed

cordyceps: List doesn't impl Drop #165

jamesmunns opened this issue May 25, 2022 · 1 comment

Comments

@jamesmunns
Copy link
Collaborator

As noticed while troubleshooting CI issues in #163, cordyceps::List does not implement Drop, meaning any items contained in that list at the time of the List falling out of scope will be permanently lost.

Additionally, the Entry type used for tests (including loom and miri tests) also does not implement drop, meaning that even if the LIST drops all of it's contained items, the individual items will likely be leaked.

Warning to Eliza: James may not actually understand how the List or List tests work, and the fact you store all the entries in a vec:

let entries: Vec<_> = (0..ops.len()).map(|i| entry(i as i32)).collect();

means that they all get dropped, and it doesn't matter that List doesn't impl drop.

Have a think about this after some coffee, and potentially close this issue if everything is working as expected.

@hawkw
Copy link
Owner

hawkw commented May 29, 2022

as we discussed on discord, it's the element owning the entry that's responsible for dropping it, rather than the list.

@hawkw hawkw closed this as completed May 29, 2022
@hawkw hawkw reopened this Jun 7, 2022
hawkw added a commit that referenced this issue Jun 7, 2022
When a linked list's `Handle` type owns the allocation for the item in
the list, it is necessary to drain all entries from the list and drop
them when the `List` instance is dropped. Otherwise, the entries may be
leaked.

This fixes a leak reported by Miri.

Fixes #165

BREAKING CHANGE:

The `List::new` constructor now requires a `T: Linked<list::Links<T>>`
bound.
hawkw added a commit that referenced this issue Jun 7, 2022
When a linked list's `Handle` type owns the allocation for the item in
the list, it is necessary to drain all entries from the list and drop
them when the `List` instance is dropped. Otherwise, the entries may be
leaked.

This fixes a leak reported by Miri.

Fixes #165

BREAKING CHANGE:

The `List::new` constructor now requires a `T: Linked<list::Links<T>>`
bound.
hawkw added a commit that referenced this issue Jun 7, 2022
When a linked list's `Handle` type owns the allocation for the item in
the list, it is necessary to drain all entries from the list and drop
them when the `List` instance is dropped. Otherwise, the entries may be
leaked.

This fixes a leak reported by Miri.

Fixes #165

BREAKING CHANGE:

The `List::new` constructor now requires a `T: Linked<list::Links<T>>`
bound.
@hawkw hawkw closed this as completed in ea7412a Jun 7, 2022
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

No branches or pull requests

2 participants