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

fix: return ENOTSUP instead of -1 for unsupported syscalls #51

Merged
merged 1 commit into from
Nov 24, 2023

Conversation

kateinoigakukun
Copy link
Contributor

@kateinoigakukun kateinoigakukun commented Nov 24, 2023

Negative errno value is not expected at least by wasi-libc and strerror(-1) returns "Success" as an undefined behavior. To avoid such confusion, it might be better to return ENOTSUP for unimplemented syscalls instead of invalid errno -1.
This change makes browser_wasi_shim work with ruby.wasm.

$ cat main.c
#include <stdio.h>
#include <string.h>

int main(void) {
    printf("%s\n", strerror(-1));
    return 0;
}
$ $WASI_SDK_PATH/bin/clang main.c
$ wasmtime a.out
Success

Negative errno value is not expected at least by wasi-libc.
@bjorn3 bjorn3 merged commit 6193f74 into bjorn3:main Nov 24, 2023
1 check passed
@bjorn3
Copy link
Owner

bjorn3 commented Nov 24, 2023

Thanks!

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

2 participants