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

Fail to get the file discriptor? #4753

Closed
Userzxcvbvnm opened this issue May 27, 2024 · 6 comments · Fixed by #4730
Closed

Fail to get the file discriptor? #4753

Userzxcvbvnm opened this issue May 27, 2024 · 6 comments · Fixed by #4730
Assignees
Labels
📦 lib-vfs About wasmer-vfs priority-high High priority issue
Milestone

Comments

@Userzxcvbvnm
Copy link
Contributor

Describe the bug

Fail to get the file descriptor, while other Wasm runtimes and native could get it successfully.

Steps to reproduce

The c file is :

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>


int get_fd(const char *filename, int flags) {
    int fd = open(filename, flags);
    
    if (fd == -1) {
        printf("Get file descriptor of file %s failed!\n", filename);
        return -1;
    } else {
        printf("Get file descriptor of file %s succeed!\n", filename);
        return fd;
    }
}


int main() {
    int fd = get_fd("./hello.txt", O_RDWR);
    return 0;
}

(1)compile to Wasm:
./wasi-sdk-21.0/bin/clang --target=wasm32-unkown-wasi --sysroot=./wasi-sdk-21.0/share/wasi-sysroot read.c -o read.wasm
(2)compile to native code:
gcc read.c -o read
(3)Running wasm:
wasmer run --dir=. read.wasm
(4)Running native binaries
./read

Expected behavior

Output:
Get file descriptor of file ./hello.txt succeed!
And this is the output of native and other Wasm runtimes, such as wasmtime.

Actual behavior

wasmer prints:
Get file descriptor of file ./hello.txt failed!

Additional context

Ubuntu 20.04
wasmer-4.3.1

@maminrayej maminrayej self-assigned this May 27, 2024
@maminrayej maminrayej added the 📦 lib-vfs About wasmer-vfs label May 27, 2024
@Userzxcvbvnm
Copy link
Contributor Author

It seems wasmer could ont open any file, whether native and other runtimes could.

@maminrayej
Copy link
Contributor

@Userzxcvbvnm could you please test your use case with #4730? since I believe this is a duplicate of #4724.

@Userzxcvbvnm
Copy link
Contributor Author

Userzxcvbvnm commented May 30, 2024

I tried my test case with the wasmer of commit 4730, but failed again with the same output I mentioned.
The steps are:
(1) git clone https://github.com/wasmerio/wasmer.git
(2)git reset --hard 6aee08d6b0e1b9a9cc38e6bef0e93c0aa3f52fe1 (set to commit 4730)
(3)make build-wasmer
(4)wasmer run --dir=. read.wasm
Print:

Get file descriptor of file ./hello.txt failed!

@maminrayej
Copy link
Contributor

Thanks for testing. I'll investigate.

@maminrayej
Copy link
Contributor

I can confirm your provided example, now works using the latest commit of #4730.

@Userzxcvbvnm
Copy link
Contributor Author

Thanks for your reply and commit!
I reproduced the test by setting Wasmer to commit d202535(the newest 4730 commit). However, I still get the result Get file descriptor of file ./hello.txt failed!.
Is there anything wrong with my command or with your code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 lib-vfs About wasmer-vfs priority-high High priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants