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
This commit is contained in:
Ayke van Laethem
2024-10-30 19:24:47 +01:00
committed by Ayke
parent f9f439ad49
commit a6c4287b4d
2 changed files with 12 additions and 10 deletions
+9 -7
View File
@@ -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
}