Skip to content

Commit

Permalink
fix: update docs for task::notification::Notifier (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-g00da authored Feb 23, 2025
1 parent 575d5c2 commit a387891
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fix the SDMMC driver for ESP-IDF V5.5+
- Fix outdated task docs

## [0.45.2] - 2025-01-15

Expand Down
20 changes: 8 additions & 12 deletions src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,13 +935,11 @@ pub mod notification {
impl Notifier {
/// # Safety
///
/// This method is unsafe because it is possible to call `core::mem::forget` on the Monitor instance
/// that produced this notifier.
/// Care should be taken to ensure that `Notifier` does not outlive the task
/// in which the `Notification` that produced it was created.
///
/// If that happens, the `Drop` dtor of `Monitor` will NOT be called, which - in turn - means that the
/// `Arc` holding the task reference will stick around even when the actual task where the `Monitor` instance was
/// created no longer exists. Which - in turn - would mean that the method will be trying to notify a task
/// which does no longer exist, which would lead to UB and specifically - to memory corruption.
/// If that happens, a dangling pointer instead of proper task handle will be passed to `task::notify`,
/// which will result in memory corruption.
pub unsafe fn notify(&self, notification: NonZeroU32) -> (bool, bool) {
let freertos_task = self.0.load(Ordering::SeqCst);

Expand All @@ -954,13 +952,11 @@ pub mod notification {

/// # Safety
///
/// This method is unsafe because it is possible to call `core::mem::forget` on the Monitor instance
/// that produced this notifier.
/// Care should be taken to ensure that `Notifier` does not outlive the task
/// in which the `Notification` that produced it was created.
///
/// If that happens, the `Drop` dtor of `Monitor` will NOT be called, which - in turn - means that the
/// `Arc` holding the task reference will stick around even when the actual task where the `Monitor` instance was
/// created no longer exists. Which - in turn - would mean that the method will be trying to notify a task
/// which does no longer exist, which would lead to UB and specifically - to memory corruption.
/// If that happens, a dangling pointer instead of proper task handle will be passed to `task::notify_and_yield`,
/// which will result in memory corruption.
pub unsafe fn notify_and_yield(&self, notification: NonZeroU32) -> bool {
let freertos_task = self.0.load(Ordering::SeqCst);

Expand Down

0 comments on commit a387891

Please sign in to comment.