-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fixed crash in posix.open when TMPFILE=true and DIRECTORY=false #20387
base: master
Are you sure you want to change the base?
Conversation
I saw some disabled tests in this file, due to #14968. Also the tests are currently only run for linux, which is overly restrictive, but I'm not entirely sure how to only enable the tests for the platforms that have .O flags, smth like @hasDecl(posix, "O") does no work, as O is defined for these, but is instead "cough" via a compileError prong. The "last resort" i guess would be to just list the relevant posix platforms manually. |
I'm not convinced this fix is correct. I can't find any code in musl or glibc that does something equivalent to this. |
I just had a look at musl's and glibc's code and they indeed do not mess with the flags like this before the syscall. They dont do this because they do not have to. They simply define the o_tmpfile constant, as such that it has the value of o_directory already or-ed into it.
in musl in the generic header it is similarly
The way zig defines these constants makes them "exclusive" so O.TMPFILE is "just" the tmp flag and does not normally implicitly include the O.DIRECTORY flag. As i said in the bug report, not sure that this should be addressed this way. The kernel expects this flag to be present. glibc and musl do this by defining the constant to always include it. One could do it this way and fix the flags after the fact or "fix" the definiton of the flag. |
Thanks for doing that research; I'd totally missed that. At minimum, we should make sure that the As for #6600 is also a reason why we likely wouldn't want to do this in Honestly, given these constraints, it seems like the best we can do is put a doc comment on |
I agree this shouldn't be fixed in wrapper code, but I think we can define
Use it like:
Maybe its better to make oflags a pointer to an in/out parameter, and return void? Or call this
I thought there was some existing packed-struct definition in Zig that solved a multiple-bits problem like this, but I can't find any. Except for definitions where the bits are adjacent, in which case an embedded Also, it looks like |
Fixes #20378.
As said in the issue, I think it would also be reasonable to solve this via returning an error instead.