-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
posix.fstatat
fails to propogate SYMLINK_NOFOLLOW
when linking wasi-libc
#20890
Comments
Co-authored-by: Ryan Liptak <[email protected]>
I've got a change with a bunch of WASI with-or-without-libc fixes coming soon, I'll see if I can fold this in. |
Clean up the std.c.S flags mapped from wasi-libc, and share them with the no-libc wasi POSIX code. Fix the wasi-libc Stat.mode field. Add a test for fstat{,at} with symlinks (for everyone, not just wasi) Fixes ziglang#20890
Clean up the std.c.S flags mapped from wasi-libc, and share them with the no-libc wasi POSIX code. Fix the wasi-libc Stat.mode field. Add a test for fstat{,at} with symlinks (for everyone, not just wasi) Fixes ziglang#20890
Clean up the std.c.S flags mapped from wasi-libc, and share them with the no-libc wasi POSIX code. Fix the wasi-libc Stat.mode field. Add a test for fstat{,at} with symlinks (for everyone, not just wasi) Fixes ziglang#20890
Clean up the std.c.S flags mapped from wasi-libc, and share them with the no-libc wasi POSIX code. Fix the wasi-libc Stat.mode field. Add a test for fstat{,at} with symlinks (for everyone, not just wasi) Fixes ziglang#20890
I think the problem is that My test show the 0x1 works, which bolsters my case, but I'm curious to know what the actual source of truth for these constants is. .. |
This might be relevant if Zig is calling into the "bottom half" of wasi-libc: https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/headers/public/__header_fcntl.h#L55 |
Add a test for fstat{,at} with symlinks (for everyone, not just wasi) Fix the wasi-libc Stat.mode field, and add the expected accessors to the S struct. Fixes ziglang#20890
Add a test for fstat{,at} with symlinks (for everyone, not just wasi) Fix the wasi-libc Stat.mode field, and add the expected accessors to the S struct. Fixes ziglang#20890
Add a test for fstat{,at} with symlinks (for everyone, not just wasi) Fix the wasi-libc Stat.mode field, and add the expected accessors to the S struct. Fixes ziglang#20890
I believe I've found the header that defines the constants that wasi-libc expects its clients to use: lib/libc/include/wasm-wasi-musl/__header_fcntl.h. (This header is included by The directory is included by wasm_libc.zig as the sysroot (the
The "bottom-half" headers I linked to earlier, as I understand it, are for the wasi-libc implementation to talk to WASI APIs, so its not directly relevant here -- though it seems like many of the constants are defined to match across the two layers. So, according to this header I have fixes for this in #20991 (along with some testcases that exercise these values). If you have a pure C compilation environment set up for WASI, you might trying |
Add a test for fstat{,at} with symlinks (for everyone, not just wasi) Fix the wasi-libc Stat.mode field, and add the expected accessors to the S struct. Fixes ziglang#20890
Zig Version
0.14.0-dev.653+91c17979f
Steps to Reproduce and Observed Behavior
This test passes normally and when targeting
wasm32-wasi
and not linking libc:But fails when linking libc (meaning
wasi-libc
):(that mode is
IFREG
aka a file)This is not a problem with the parameters being passed to
fstatat
: I confirmed that theAT_SYMLINK_NOFOLLOW
is being passed to thefstatat_sym
call here:zig/lib/std/posix.zig
Line 4382 in 059856a
But
strace
shows that theNOFOLLOW
flag is being dropped when going throughwasmtime
(theopenat2
call should haveO_NOFOLLOW
, which it does when not linkingwasi-libc
):My first thought was that this is a
wasi-libc
/wasmtime
bug, similar to #20747, but I have been unable to find a reproduction when building an intended-to-be-equivalent C version viawasi-sdk
. Here's the program I'm trying (I'm usingwasi-sdk 23.0
andwasmtime 23.0.1
):Built with:
And run with:
(0xA000 is S_IFLNK aka symlink)
Expected Behavior
The test to pass when linking
wasi-libc
The text was updated successfully, but these errors were encountered: