Skip to content

Commit 78a4ee1

Browse files
committed
Merge pull request #1460 from pguyot/w02/fix-race-condition-in-timeout
Fix race condition in timeout handling These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents dfc3bf1 + 777a1ba commit 78a4ee1

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)