Skip to content

WASI preview 1 error handling #660

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

Open
divergentdave opened this issue May 1, 2025 · 1 comment · May be fixed by #661
Open

WASI preview 1 error handling #660

divergentdave opened this issue May 1, 2025 · 1 comment · May be fixed by #661

Comments

@divergentdave
Copy link
Contributor

I noticed that the code for the wasi_p1 backend now uses Error::from_neg_error_code(). WASI preview 1 error codes are unsigned 16-bit integers in the witx definition, though they are passed as signed 32-bit integers at the WASM level. The error values start at 1 and go up, so the code < 0 check transforms all errors into Error::UNEXPECTED. I confirmed this by calling getrandom from within a runtime that had a custom random_get import. I think this will need a separate constructor method, similar to Error::from_uefi_code().

@newpavlov newpavlov linked a pull request May 4, 2025 that will close this issue
@newpavlov
Copy link
Member

I think it's easier to just negate the code and continue to use from_neg_error_code. In the PR I also added a check that the code is in the expected range.

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 a pull request may close this issue.

2 participants