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/run_queue.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/run_queue.rs')
| -rw-r--r-- | embassy-executor/src/executor/raw/run_queue.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/embassy-executor/src/executor/raw/run_queue.rs b/embassy-executor/src/executor/raw/run_queue.rs index 31615da7e..ed8c82a5c 100644 --- a/embassy-executor/src/executor/raw/run_queue.rs +++ b/embassy-executor/src/executor/raw/run_queue.rs | |||
| @@ -46,10 +46,10 @@ impl RunQueue { | |||
| 46 | /// | 46 | /// |
| 47 | /// `item` must NOT be already enqueued in any queue. | 47 | /// `item` must NOT be already enqueued in any queue. |
| 48 | #[inline(always)] | 48 | #[inline(always)] |
| 49 | pub(crate) unsafe fn enqueue(&self, _cs: CriticalSection, task: *mut TaskHeader) -> bool { | 49 | pub(crate) unsafe fn enqueue(&self, _cs: CriticalSection, task: NonNull<TaskHeader>) -> bool { |
| 50 | let prev = self.head.load(Ordering::Relaxed); | 50 | let prev = self.head.load(Ordering::Relaxed); |
| 51 | (*task).run_queue_item.next.store(prev, Ordering::Relaxed); | 51 | task.as_ref().run_queue_item.next.store(prev, Ordering::Relaxed); |
| 52 | self.head.store(task, Ordering::Relaxed); | 52 | self.head.store(task.as_ptr(), Ordering::Relaxed); |
| 53 | prev.is_null() | 53 | prev.is_null() |
| 54 | } | 54 | } |
| 55 | 55 | ||
