diff options
author | Ayke van Laethem <[email protected]> | 2024-10-30 19:24:47 +0100 |
---|---|---|
committer | Ayke <[email protected]> | 2024-11-07 15:37:18 +0100 |
commit | a6c4287b4d2dc8c951227820a1dbc69d7e26b689 (patch) | |
tree | fcb3f263e4e26f4bdd41f57c1a075eb69f4e0d26 /src | |
parent | f9f439ad49ef8a21e373568277aff8e448806cf2 (diff) | |
download | tinygo-a6c4287b4d2dc8c951227820a1dbc69d7e26b689.tar.gz tinygo-a6c4287b4d2dc8c951227820a1dbc69d7e26b689.zip |
runtime: don't call sleepTicks with a negative duration
There are rare cases where this can happen, see for example
https://github.com/tinygo-org/tinygo/issues/4568
Diffstat (limited to 'src')
-rw-r--r-- | src/runtime/scheduler.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/runtime/scheduler.go b/src/runtime/scheduler.go index 3f726a064..203e954c3 100644 --- a/src/runtime/scheduler.go +++ b/src/runtime/scheduler.go @@ -230,13 +230,15 @@ func scheduler(returnAtDeadlock bool) { println("--- timer waiting:", tim, tim.whenTicks()) } } - sleepTicks(timeLeft) - if asyncScheduler { - // The sleepTicks function above only sets a timeout at which - // point the scheduler will be called again. It does not really - // sleep. So instead of sleeping, we return and expect to be - // called again. - break + if timeLeft > 0 { + sleepTicks(timeLeft) + if asyncScheduler { + // The sleepTicks function above only sets a timeout at + // which point the scheduler will be called again. It does + // not really sleep. So instead of sleeping, we return and + // expect to be called again. + break + } } continue } |