From 2668619143ceba8e70dc3d356ddb44d23349e039 Mon Sep 17 00:00:00 2001 From: Hendrik Date: Sun, 17 May 2026 07:31:08 +0200 Subject: [PATCH] Improve wakeup tick condition check We got a off by one error here, checking against UINT32_MAX doesn't silently set a wrong value. When running the task mgem with a busy loop this doesn't cause an issue, but with a tickless timer only one timer ever gets fired and then the task mgem stops working. --- mrbgems/mruby-task/src/task.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mrbgems/mruby-task/src/task.c b/mrbgems/mruby-task/src/task.c index 7e364cbca..afe9b2438 100644 --- a/mrbgems/mruby-task/src/task.c +++ b/mrbgems/mruby-task/src/task.c @@ -568,7 +568,8 @@ sleep_us_impl(mrb_state *mrb, uint32_t usec) t->wait.wakeup_tick = tick_ + USEC_TO_TICKS(usec); /* Update next wakeup time if this task wakes earlier */ - if ((int32_t)(t->wait.wakeup_tick - wakeup_tick_) < 0) { + if (wakeup_tick_ == UINT32_MAX || + (int32_t)(t->wait.wakeup_tick - wakeup_tick_) < 0) { wakeup_tick_ = t->wait.wakeup_tick; }