emscripten-core / emscripten-core/emscripten

WASM_STANDALONE: Errno 63 (Out of stream resources) at fopen call

Đang mở
#17,167 15 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
27.6k
Fork
3.6k
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
109

Mô tả

**Error description:**
I'm trying to build a standalone WASM module which is reading from a file by using WASI.
The compilation is done by running the following command:
```
emcc filetest.c -o filetest.wasm --no-entry -s ERROR_ON_UNDEFINED_SYMBOLS=0
```
The compilation works fine and succeeds without an error.

I'm using wasmtime in order to run the module:
```
wasmtime filetest.wasm --dir . --invoke filetest
```
In my working directory, there is a file 'test.txt', which only contains one line with the content "test".
Running the WASM module by using the previously mentioned command, I'm getting the following output:
```
Fopen failed, errno = 63
```
Looking up the meaning of errno 63, there seems to be an issue with stream resources:
```
ENOSR 63 Out of streams resources
```

I also activated the wasmtime WASI trace logging by setting the environment variable *RUST_LOG* to *wasi_common=trace*. Running the wasmtime command now prints the following output:
```
TRACE wasi_common::snapshots::preview_1::wasi_snapshot_preview1 > wiggle abi; module="wasi_snapshot_preview1" function="fd_write"
TRACE wasi_common::snapshots::preview_1::wasi_snapshot_preview1 > fd=Fd(1) iovs=*guest 0x500e40/2
Fopen failed, errno = 63 TRACE wasi_common::snapshots::preview_1::wasi_snapshot_preview1 > result=Ok(24)
TRACE wasi_common::snapshots::preview_1::wasi_snapshot_preview1 > wiggle abi; module="wasi_snapshot_preview1" function="proc_exit"
TRACE wasi_common::snapshots::preview_1::wasi_snapshot_preview1 > rval=1
TRACE wasi_common::snapshots::preview_1::wasi_snapshot_preview1 > result=I32Exit(1)
```
This log shows that no open- or read-call was performed. There is only a fd_write-call, that prints the error message to the stdout file descriptor.

What is the reason behind this error and what can I do in order to get my example running?

**Example code:**
```
#include
#include
#include
#include

EMSCRIPTEN_KEEPALIVE void filetest() {
FILE *handle = fopen("test.txt", "r");

if (handle == NULL) {
printf("Fopen failed, errno = %d", errno);
exit(EXIT_FAILURE);
}

fclose(handle);
}
```

**Version of emscripten/emsdk:**
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.13 (531257621816c200bc7c3be53129494afd029aec)
clang version 15.0.0 (https://github.com/llvm/llvm-project 5c6ed60c517c47b25b6b25d8ac3666d0e746b0c3)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.