Skip to content

Commit

Permalink
Rollup merge of rust-lang#56319 - RalfJung:async-mutable-ref, r=cramertj
Browse files Browse the repository at this point in the history
fix futures creating aliasing mutable and shared ref

Fixes the problem described in rust-lang/miri#532 (comment): `set_task_waker` takes a shared reference and puts a copy into the TLS (in a `NonNull`), but `get_task_waker` gets it back out as a mutable reference. That violates "mutable references must not alias anything"!
  • Loading branch information
GuillaumeGomez committed Nov 29, 2018
2 parents 9a5725c + 46a6831 commit 79f02e4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libstd/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ where
});
let _reset_waker = SetOnDrop(waker_ptr);

let mut waker_ptr = waker_ptr.expect(
let waker_ptr = waker_ptr.expect(
"TLS LocalWaker not set. This is a rustc bug. \
Please file an issue on https://github.com/rust-lang/rust.");
unsafe { f(waker_ptr.as_mut()) }
unsafe { f(waker_ptr.as_ref()) }
}

#[unstable(feature = "gen_future", issue = "50547")]
Expand Down

0 comments on commit 79f02e4

Please sign in to comment.