-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wasmtime-wasi] fix logic error in
monotonic-clock/subscribe
(#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>
- Loading branch information
1 parent
d0d21bc
commit 0ca0fae
Showing
9 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use crate::wasi::{clocks::monotonic_clock, poll::poll}; | ||
|
||
wit_bindgen::generate!({ | ||
path: "../../wasi/wit", | ||
world: "wasmtime:wasi/command-extended", | ||
}); | ||
|
||
fn main() { | ||
// Sleep ten milliseconds. Note that we call the relevant host functions directly rather than go through | ||
// libstd, since we want to ensure we're calling `monotonic_clock::subscribe` with an `absolute` parameter of | ||
// `true`, which libstd won't necessarily do (but which e.g. CPython _will_ do). | ||
poll::poll_oneoff(&[monotonic_clock::subscribe( | ||
monotonic_clock::now() + 10_000_000, | ||
true, | ||
)]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters