From 46a3f2befd6fd821e5747ce9db112c550bc989f3 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Fri, 5 Aug 2022 11:28:02 +0200 Subject: 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 --- examples/async-task-multiple-prios.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'examples/async-task-multiple-prios.rs') diff --git a/examples/async-task-multiple-prios.rs b/examples/async-task-multiple-prios.rs index a90c11bd..d47e87b1 100644 --- a/examples/async-task-multiple-prios.rs +++ b/examples/async-task-multiple-prios.rs @@ -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(); } -- cgit v1.2.3