Fix UB in the access of Priority for asyc executors

The `Priority` was generated on the stack in the dispatcher
which caused it to be dropped after usage. This is now fixed
by having the `Priority` being a static variable for executors
This commit is contained in:
Emil Fresk 2022-08-05 11:28:02 +02:00
parent b48a95e879
commit 46a3f2befd
5 changed files with 42 additions and 15 deletions

View file

@ -16,7 +16,10 @@ mod app {
use systick_monotonic::*;
#[shared]
struct Shared {}
struct Shared {
a: u32,
b: u32,
}
#[local]
struct Local {}
@ -34,7 +37,7 @@ mod app {
async_task2::spawn().ok();
(
Shared {},
Shared { a: 0, b: 0 },
Local {},
init::Monotonics(Systick::new(cx.core.SYST, 12_000_000)),
)
@ -49,24 +52,24 @@ mod app {
}
}
#[task(priority = 1)]
#[task(priority = 1, shared = [a, b])]
fn normal_task(_cx: normal_task::Context) {
hprintln!("hello from normal 1").ok();
}
#[task(priority = 1)]
#[task(priority = 1, shared = [a, b])]
async fn async_task(_cx: async_task::Context) {
hprintln!("hello from async 1").ok();
debug::exit(debug::EXIT_SUCCESS);
}
#[task(priority = 2)]
#[task(priority = 2, shared = [a, b])]
fn normal_task2(_cx: normal_task2::Context) {
hprintln!("hello from normal 2").ok();
}
#[task(priority = 2)]
#[task(priority = 2, shared = [a, b])]
async fn async_task2(_cx: async_task2::Context) {
hprintln!("hello from async 2").ok();
}