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

noop_waker_ref is unsound #2091

Closed
goffrie opened this issue Mar 3, 2020 · 1 comment · Fixed by #2095
Closed

noop_waker_ref is unsound #2091

goffrie opened this issue Mar 3, 2020 · 1 comment · Fixed by #2095
Labels
A-task Area: futures::task bug

Comments

@goffrie
Copy link
Contributor

goffrie commented Mar 3, 2020

Demo which segfaults in playground:

use futures::task::noop_waker_ref;
fn main() {
    let waker = std::thread::spawn(|| noop_waker_ref()).join().unwrap();
    waker.wake_by_ref();
}

noop_waker_ref() returns a 'static reference into TLS, but Waker is Sync so &'static Waker is Send, allowing the reference to outlive the thread it came from.

It should use something more like a lazy_static.

@Nemo157
Copy link
Member

Nemo157 commented Mar 5, 2020

@goffrie thanks, opened #2095 which should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-task Area: futures::task bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants