-
Notifications
You must be signed in to change notification settings - Fork 191
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
fopen
/openat
does not seem to preserve access flags
#415
Comments
Can you please run wasmtime with the environment variable |
|
The behavior changed in Log from |
diff between wasmtime 8 and wasmtime 9, with the same wasm file. |
Thanks. Can you please move this bug over to the wasmtime repository? This appears to be a bug over there, not in wasi-libc. |
Something changed in wasmtime, but I'm not sure Looking at the traces, for the same code, this is what we see without
and with
|
This is the |
Just to make a clarification:
This is referring to how the problem was manifesting in the Zig test suite, where it'd try to open a directory with The reproduction in the OP of this issue does not include that wrinkle and is instead focused on just the flags being passed to the syscall, since I realized the problem is more general than just opening directories for writing. |
This is a bug in Wasmtime 9.0.{0,1}. I have prepared a fix which we will release as 9.0.2. The behavior is the same across wasi-sdk 19 and 20, I did not test any further back but I believe it is the same for a long time. In the original test case given, this line:
will actually open a file read-only. The mode string to open read-write is I made variants of that test for read-only (
|
Awesome! Thank you Pat! |
Tested on Linux with
wasmtime
v9.0.1
andwasi-sdk-20.0
.The following code (saved as
open-rw.c
) tries to open a file (that exists) for reading and writing:EDIT: The above code originally used the invalid flags
"rw"
, it has been corrected to use"w"
However, when using
wasi-libc
, the actual syscall (for me it'sopenat2
) is being passedO_RDONLY
instead of the expectedO_WRONLY
. Note: same applies toO_RDWR
,O_RDONLY
is still passed instead.Compiled with
wasi-sdk-20.0
:Note that access flags are preserved in the equivalent Zig code (unless
-lc
to link libc is used in which casewasi-libc
is built/linked and theO_RDONLY
behavior occurs)And are also preserved in the equivalent Rust code:
The text was updated successfully, but these errors were encountered: