Skip to content
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

std.os.windows: handle OBJECT_NAME_INVALID in OpenFile #19288

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

marler8997
Copy link
Contributor

@marler8997 marler8997 commented Mar 13, 2024

It's been seen on Windows 11 (22H2) Build 22621.3155 that NtCreateFile will return the OBJECT_NAME_INVALID error code with certain path names. The path name we saw this with started with C:Users (rather than C:\Users) and also contained a $ character. This PR updates our OpenFile wrapper to propagate this error code as error.BadPathName instead of making it unreachable.

NOTE: not all versions of windows will return this error code, some will return OBJECT_PATH_NOT_FOUND instead

see marler8997/zigup#114 (comment)

It's been seen on Windows 11 (22H2) Build 22621.3155 that NtCreateFile
will return the OBJECT_NAME_INVALID error code with certain path names.
The path name we saw this with started with `C:Users` (rather than
`C:\Users`) and also contained a `$` character.  This PR updates our
OpenFile wrapper to propagate this error code as `error.BadPathName`
instead of making it `unreachable`.

see marler8997/zigup#114 (comment)
@squeek502
Copy link
Collaborator

Contributes towards #15607

@marler8997
Copy link
Contributor Author

Oh I didn't realize we we considering a validation strategy as an alternative solution. Interesting...

@squeek502
Copy link
Collaborator

squeek502 commented Mar 14, 2024

Oh I didn't realize we we considering a validation strategy as an alternative solution.

We're not. The state of that issue is that unreachable for invalid path names is now considered a bug, so this PR is the right way to go.

@andrewrk
Copy link
Member

Would be nice to have some doc comments on that new error code to provide some insight to developers on the conditions it might occur, but happy to merge this in the meantime.

@andrewrk andrewrk merged commit 32f602a into ziglang:master Mar 14, 2024
10 checks passed
@marler8997 marler8997 deleted the windowsObjectNameInvalid branch March 14, 2024 04:51
RossComputerGuy pushed a commit to ExpidusOS-archive/zig that referenced this pull request Mar 20, 2024
It's been seen on Windows 11 (22H2) Build 22621.3155 that NtCreateFile
will return the OBJECT_NAME_INVALID error code with certain path names.
The path name we saw this with started with `C:Users` (rather than
`C:\Users`) and also contained a `$` character.  This PR updates our
OpenFile wrapper to propagate this error code as `error.BadPathName`
instead of making it `unreachable`.

see marler8997/zigup#114 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants