Skip to content

Commit 777a1ba

Browse files
committed
Fix race condition in timeout handling
Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent dfc3bf1 commit 777a1ba

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ certain VM instructions are used.
2727
- Fixed an issue where a timeout would occur immediately in a race condition
2828
- Fixed SPI close command
2929
- Added missing lock on socket structure
30+
- Fixed a race condition affecting multi-core MCUs where a timeout would not be properly cleared
3031

3132
## [0.6.5] - 2024-10-15
3233

src/libAtomVM/scheduler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,11 +414,11 @@ void scheduler_cancel_timeout(Context *ctx)
414414
{
415415
GlobalContext *glb = ctx->global;
416416

417-
context_update_flags(ctx, ~(WaitingTimeout | WaitingTimeoutExpired), NoFlags);
418-
419417
struct TimerList *tw = &glb->timer_list;
420418

421419
SMP_SPINLOCK_LOCK(&glb->timer_spinlock);
422420
timer_list_remove(tw, &ctx->timer_list_head);
423421
SMP_SPINLOCK_UNLOCK(&glb->timer_spinlock);
422+
423+
context_update_flags(ctx, ~(WaitingTimeout | WaitingTimeoutExpired), NoFlags);
424424
}

0 commit comments

Comments
 (0)