New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: skip negative sleep durations in sleepTicks #4239
Conversation
7e9c147
to
3b691fb
Compare
The CI failure
is surprising. It seems that TinyGo fails to compile the expression
|
3b691fb
to
499f265
Compare
WorksForMe(tm):
|
Works for me locally as well, but not in CI. I can reproduce the error locally with this diff:
and
|
For which target does this fail? If it's for wasm, then that makes sense: we use float64 for I need to look at the logic of this PR another time. |
@aykevl Ah, float for the js runtime. Good catch! I'll see if that's the case. |
Yup, almost certainly. I don't think we can reasonably do anything to fix the compilation error, since we're using wasm for those unit tests. |
The real issue seems to be that rp2040 is the only system where With that fix, every target (except for wasm) will use int64. I think it makes sense to convert wasm to int64 too to get rid of inconsistencies like these and just define |
sleepTicks calls machineLightSleep with the duration cast to an unsigned integer. This underflow for negative durations. Signed-off-by: Elias Naur <mail@eliasnaur.com>
499f265
to
b043f57
Compare
Thanks @aykevl, I completely missed both the inconsistent timerUnit and the WASM float variant. I've updated the PR with the only remaining issue: |
Yes that change looks entirely reasonable! Thank you for the fix! |
I can't get
make test
to run on my Nix/macOS setup, but here's a program that hangs without this change on targetpico
:I tried minimizing it even further, but removing a print or dummy channel makes the hang disappear.