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

Does this crate alias mutable references? #56

Open
Kestrer opened this issue Jan 21, 2021 · 1 comment
Open

Does this crate alias mutable references? #56

Kestrer opened this issue Jan 21, 2021 · 1 comment

Comments

@Kestrer
Copy link

Kestrer commented Jan 21, 2021

I'm pretty sure this crate ends up aliasing mutable references, as each future, when polled, holds a mutable reference to the data at the same time as the linked list does.

As an example: suppose there is a ManualResetEvent, and this happens:

  • .wait() is called, and the future is polled once. This will insert a raw pointer to its WaitQueueEntry inside the ManualResetEvent's linked list.
  • At this point, we have a mutable reference to the WaitQueueEntry transitively through the future.
  • .set() is called. This then calls LinkedList::reverse_drain, which creates a &mut ListNode<WaitQueueEntry> that aliases with the one held by the future. This is UB.

However I couldn't get Miri to trigger on this, so I'm not sure.

@goffrie
Copy link
Contributor

goffrie commented Jan 27, 2021

I believe this is true, but I also don't think it's possible to resolve this without something like AliasedCell from rust-lang/rust#63818, because Future::poll receives a Pin<&mut Self> argument and therefore always borrows the entire thing, even if we don't want to.

IIRC a number of tests in this crate fail under miri because of this.

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