-
Notifications
You must be signed in to change notification settings - Fork 811
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
[WASI] Failed to find a pre-opened file descriptor #2079
Comments
Currently in Rust we can really only create WASI binaries, not libraries. WASI only works for the duration of a main function that needs to be there. Calling the wasi functions from anywhere else segfaults because libpreopen isn't initialized. So to summarize, how to fix this currently:
|
In my case: #![no_main]
#[no_mangle]
pub extern "C" fn start() {
std::fs::read_dir("/").unwrap();
} ...
let start = instance.exports.get_function("_initialize")?;
start.call(&[])?;
let start = instance.exports.get_function("start")?;
start.call(&[])?;
... RUSTFLAGS="-Z wasi-exec-model=reactor" cargo +nightly build -p wasi_fs_example --target wasm32-wasi |
Interesting thanks for the info! One thing I immediately noticed is the name of your start function. Wasmer CLI calls Edit: it wasn't clear to me upon first reading this issue but it seems like you've solved it! Is there are underlying issue here you'd still like resolved on wasmer's end? |
@MarkMcCaskey Oh, consider that there is the name |
We believe this issue was fixed by #2941. We need to create a test verifying this |
After some fideling with the tests, I realized it's already there: |
I wrote a simple wasmer-wasi example that reads directory entries but it always fails.
wasi_fs_example/src/lib.rs
:runner/src/main.rs
:This produce the error while running:
Full source code of the example is located here. Why doesn't it work?
The text was updated successfully, but these errors were encountered: