From 64185d06da03f1415d2f7293e062fcaceca4c502 Mon Sep 17 00:00:00 2001 From: Weiteng Chen Date: Wed, 1 Jul 2026 10:02:53 -0700 Subject: [PATCH] Fix alarm spin test overflow (#989) Fix the userspace alarm spin test so its loop does not escape within one second (switching from signed `int` to unsigned `long long`). --- litebox_runner_linux_userland/tests/alarm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/litebox_runner_linux_userland/tests/alarm.c b/litebox_runner_linux_userland/tests/alarm.c index 4938dbd065..c996353adb 100644 --- a/litebox_runner_linux_userland/tests/alarm.c +++ b/litebox_runner_linux_userland/tests/alarm.c @@ -139,11 +139,10 @@ int test_alarm_fires_in_userspace(void) { // Busy-wait (no syscalls) until SIGALRM arrives. // The platform's schedule_interrupt mechanism should interrupt us. - volatile int i = 0; + volatile unsigned long long iterations = 0; while (alarm_count == 0) { - i++; - // Avoid the compiler optimizing this away. - if (i < 0) + iterations++; + if (iterations == 0) break; } @@ -153,7 +152,7 @@ int test_alarm_fires_in_userspace(void) { sa.sa_handler = SIG_DFL; sigaction(SIGALRM, &sa, NULL); - printf("alarm_fires_in_userspace: PASS (loop iterations=%d)\n", i); + printf("alarm_fires_in_userspace: PASS (loop iterations=%llu)\n", iterations); return 0; }