Skip to content
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

[wasmtime-wasi] fix logic error in monotonic-clock/subscribe #6993

Merged

Conversation

dicej
Copy link
Collaborator

@dicej dicej commented Sep 11, 2023

When calculating the number of nanoseconds to wait, we should subtract the current time from the deadline, not vice-versa. This was causing guests to sleep indefinitely due to integer underflow.

When calculating the number of nanoseconds to wait, we should subtract the
current time from the deadline, not vice-versa.  This was causing guests to
sleep indefinitely due to integer underflow.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
@dicej dicej requested a review from a team as a code owner September 11, 2023 16:06
@dicej dicej requested review from alexcrichton and removed request for a team September 11, 2023 16:06
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Would it be possible to add a test for this as well?

Note that this is annotated `should_panic` when testing preview1 scenarios,
since those won't have preview2 imports.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
@dicej dicej requested a review from a team as a code owner September 11, 2023 17:06
@dicej
Copy link
Collaborator Author

dicej commented Sep 11, 2023

I've added a test.

@pchickey pchickey added this pull request to the merge queue Sep 11, 2023
Merged via the queue into bytecodealliance:main with commit 186c3ec Sep 11, 2023
18 checks passed
alexcrichton pushed a commit that referenced this pull request Sep 12, 2023
* [wasmtime-wasi] fix logic error in `monotonic-clock/subscribe`

When calculating the number of nanoseconds to wait, we should subtract the
current time from the deadline, not vice-versa.  This was causing guests to
sleep indefinitely due to integer underflow.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>

* add `sleep` test to `wasi-tests`

Note that this is annotated `should_panic` when testing preview1 scenarios,
since those won't have preview2 imports.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>

---------

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
eduardomourar pushed a commit to eduardomourar/wasmtime that referenced this pull request Sep 13, 2023
…odealliance#6993)

* [wasmtime-wasi] fix logic error in `monotonic-clock/subscribe`

When calculating the number of nanoseconds to wait, we should subtract the
current time from the deadline, not vice-versa.  This was causing guests to
sleep indefinitely due to integer underflow.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>

* add `sleep` test to `wasi-tests`

Note that this is annotated `should_panic` when testing preview1 scenarios,
since those won't have preview2 imports.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>

---------

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants