diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-08-01 12:33:58 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-08-01 12:33:58 +0000 |
| commit | 2b0786129aacb0c5089e74415f45617bbf07a3eb (patch) | |
| tree | 66a63364b921a9e0c72158d33656d3e15999186d /embassy-executor/src/executor/raw/waker.rs | |
| parent | bd6bab1625d90a2dc2a4b57b40dcfaa9516bf791 (diff) | |
| parent | 8d24cba72d6a36533d6858da0e9e2ab9406a420f (diff) | |
Merge #887
887: executor: miri fixes r=Dirbaio a=Dirbaio
Fixes a few MIRI errors due to loosely mixing `&TaskStorage<F>` and `&TaskHeader`. References "downgrade" the provenance. `TaskHeader` is smaller, so once you have a `&TaskHeader` you can't use pointer casts to access the whole `TaskStorage<F>`. This fixes it by always keeping the raw pointer around, which doesn't downgrade provenance.
The error was:
```
[dirbaio@mars std]$ MIRIFLAGS=-Zmiri-disable-isolation cargo miri run --bin tick
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Running `/home/dirbaio/.rustup/toolchains/nightly-2022-07-13-x86_64-unknown-linux-gnu/bin/cargo-miri target/miri/x86_64-unknown-linux-gnu/debug/tick`
error: Undefined Behavior: trying to reborrow <12349> for SharedReadWrite permission at alloc2[0x30], but that tag does not exist in the borrow stack for this location
--> /home/dirbaio/embassy/embassy/embassy-executor/src/executor/raw/mod.rs:162:20
|
162 | let this = &*(p.as_ptr() as *const TaskStorage<F>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| trying to reborrow <12349> for SharedReadWrite permission at alloc2[0x30], but that tag does not exist in the borrow stack for this location
| this error occurs as part of a reborrow at alloc2[0x30..0x40]
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <12349> was created by a retag at offsets [0x0..0x30]
--> src/bin/tick.rs:15:1
|
15 | #[embassy_executor::main]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
= note: backtrace:
= note: inside `embassy_executor::executor::raw::TaskStorage::<std::future::from_generator::GenFuture<[static generator@src/bin/tick.rs:15:1: 15:26]>>::poll` at /home/dirbaio/embassy/embassy/embassy-executor/src/executor/raw/mod.rs:162:20
= note: inside closure at /home/dirbaio/embassy/embassy/embassy-executor/src/executor/raw/mod.rs:390:13
= note: inside `embassy_executor::executor::raw::run_queue::RunQueue::dequeue_all::<[closure@embassy_executor::executor::raw::Executor::poll::{closure#1}]>` at /home/dirbaio/embassy/embassy/embassy-executor/src/executor/raw/run_queue.rs:69:13
= note: inside `embassy_executor::executor::raw::Executor::poll` at /home/dirbaio/embassy/embassy/embassy-executor/src/executor/raw/mod.rs:373:9
= note: inside `embassy_executor::executor::Executor::run::<[closure@src/bin/tick.rs:15:1: 15:26]>` at /home/dirbaio/embassy/embassy/embassy-executor/src/executor/arch/std.rs:52:22
```
Co-authored-by: Dario Nieuwenhuis <[email protected]>
Diffstat (limited to 'embassy-executor/src/executor/raw/waker.rs')
| -rw-r--r-- | embassy-executor/src/executor/raw/waker.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/embassy-executor/src/executor/raw/waker.rs b/embassy-executor/src/executor/raw/waker.rs index f6ae332fa..6b9c03a62 100644 --- a/embassy-executor/src/executor/raw/waker.rs +++ b/embassy-executor/src/executor/raw/waker.rs | |||
| @@ -2,7 +2,7 @@ use core::mem; | |||
| 2 | use core::ptr::NonNull; | 2 | use core::ptr::NonNull; |
| 3 | use core::task::{RawWaker, RawWakerVTable, Waker}; | 3 | use core::task::{RawWaker, RawWakerVTable, Waker}; |
| 4 | 4 | ||
| 5 | use super::TaskHeader; | 5 | use super::{wake_task, TaskHeader}; |
| 6 | 6 | ||
| 7 | const VTABLE: RawWakerVTable = RawWakerVTable::new(clone, wake, wake, drop); | 7 | const VTABLE: RawWakerVTable = RawWakerVTable::new(clone, wake, wake, drop); |
| 8 | 8 | ||
| @@ -11,7 +11,7 @@ unsafe fn clone(p: *const ()) -> RawWaker { | |||
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | unsafe fn wake(p: *const ()) { | 13 | unsafe fn wake(p: *const ()) { |
| 14 | (*(p as *mut TaskHeader)).enqueue() | 14 | wake_task(NonNull::new_unchecked(p as *mut TaskHeader)) |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | unsafe fn drop(_: *const ()) { | 17 | unsafe fn drop(_: *const ()) { |
