Fix error result of clock_time_get #6812
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes the behavior of the
clock_time_get
function implemented in the preview2 adapter in case of being called with an unsupported clock id.Previously it ran onto
unreachable
, with this change it fails withERRNO_BADF
.The motivation is to get the same behavior as the preview1 WASI implementation. (
wasmtime/crates/wasi/src/preview2/preview1/mod.rs
Lines 759 to 760 in bb3734b
(I ran into this difference when tried to run a
ruby.wasm
module converted into a component using the preview2 adapter. Seems like Ruby queries all 4 clocks during startup but handles the BADF response properly.)