-
Notifications
You must be signed in to change notification settings - Fork 9
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
select/join allows for moving pinned futures #2
Comments
Well, thanks for finding this bug anyway! I'll have to fix this. |
|
Much obliged. Thanks for the fast response! |
So I looked at the fix. It looks mostly good, what I'd be concerned of would be if A "safer" fix in my view would be to constrain the Another note is that I believe the let mut v = (fut,);
v.join().await;
// future can now be freely moved out of `v`.
let (fut,) = v; So you'd probably want to add the same |
Oh wow, thanks! For some reason I thought join was implemented differently, but it looks like it's the same. I'll have to try that with Select, getting rid of the unsafe code in it would be nice! Re openning as it's the same problem that needs to get fixed, even though a different type. |
I made some changes that'll hopefully fix those problems. I'll wait for you to let me know if it all "looks good" before I close the issue again and release a new version with the changes. Thanks a ton! |
Yeah, from a cursory glance it looks correct to me. Thanks! |
Sorry to be the bearer of bad news. Pinning is a tricky subject and can be quite subtle.
Describe the bug
The current implementation of
select
allows for moving a future which is assumed to be pinned. Among other potential issues, this enables reading freed memory in safe code.To Reproduce
The following should showcase the issue:
Edit: More compact example, and a bit more comments.
Running it in debug mode for me gives:
In effect: The second read of the reference to
&foo
uses an outdated memory location, since the future has been moved the second time it was polled.Expected behavior
The
select
implementation should require the futures to beUnpin
, or maintainPin
invariants in some other way to prevent this from compiling.The text was updated successfully, but these errors were encountered: