Skip to content

time: fix deadlock between schedule_wake() and the std alarm thread - #6721

Open
leftger wants to merge 2 commits into
embassy-rs:mainfrom
leftger:fix/embassy-time
Open

time: fix deadlock between schedule_wake() and the std alarm thread#6721
leftger wants to merge 2 commits into
embassy-rs:mainfrom
leftger:fix/embassy-time

Conversation

@leftger

@leftger leftger commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a deadlock in the std time driver (embassy-time/src/driver_std.rs) between TimeDriver::schedule_wake() and alarm_thread().

  • schedule_wake(): locks the queue Mutex first, then enters the critical section.
  • alarm_thread(): enters the critical section first, then locks the queue Mutex.

Fix

Don't use the critical_section::with() wrappers around next_expiration() in both schedule_wake() and alarm_thread()

@leftger leftger added the e-time label Aug 6, 2026
Drop the critical_section::with() wrappers on the std driver; the
queue Mutex already provides the necessary synchronization.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant