-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Implement path_link for Windows. #1199
Conversation
The test failure seems unrelated to this change. (some cranelift/codegen issues) |
It's hard to see because we output so much junk with
|
5a7b9c6
to
94a29ca
Compare
You're right. Unfortunately, I can't reproduce the error locally, the tests always succeed. I'm running the tests on Windows 10, they succeed both when run through msys64 ssh and windowed cmd (as administrator). I'm using Could you try and see if you can reproduce it? |
I'll see if I can reproduce it. |
I'm unable to reproduce the failure locally as well. I tried rerunning the GitHub actions jobs, but that apparently is broken (seems to checkout the wasmtime repo and then try to checkout your HEAD, but it obviously isn't in the history 🤷♂). The expect message of To restart CI, let's rebase this branch off of master and push it up. |
I rebased upon latest master. The message is coming from |
Oh, |
As far as mapping of error codes is concerned, yeah, MSDN is not very instructive. When I was figuring out |
Also, thanks for the link! I'll need to investigate MacOS a bit further I think! |
} else if !old_path.exists() { | ||
// attempt to create a dangling symlink | ||
warn!("Dangling symlink or symlink loops unsupported on Windows"); | ||
Err(Error::ENOTSUP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good choice of errno value here, but I'd like @sunfishcode to double check that though.
22a3a24
to
43195ad
Compare
I tried to integrate those two tests into one and it appears that creating dangling symlinks doesn't fail when it should. I'll need to see why. The previous version of the branch is available here: https://github.com/marmistrz/wasmtime/tree/path_link_old |
Subscribe to Label ActionThis issue or pull request has been labeled: "wasi", "wasi:impl", "wasi:tests" Users Subscribed to "wasi"To subscribe or unsubscribe from this label, edit the |
d05a9f0
to
adf86e4
Compare
Good news! I have managed to isolate the cause of the mysterious CI failures. It appears that after calling Support for The change is mostly ready. I'm still not sure if the |
I don't particularly see how the problem lies with I do see how the test was missing calls to If we uncomment the |
If we uncomment the following lines: https://github.com/bytecodealliance/wasmtime/pull/1199/files#diff-6242b29603dfbc39ebbd9f3e58dde615R98-R102 |
@peterhuene @marmistrz did you manage to work out what the problem is? If not, what do you think the next steps should be both wrt the problem and this PR? |
I haven't yet determined the problem and I have no educated guesses since the commented out lines should have absolutely no impact on handle reference counts that might keep things from being deleted properly. @marmistrz when you get a chance, can you uncomment out the problematic lines and push it up for CI to fail again? I'd like to investigate the log just a little more. |
I thought about merging this PR as-is and letting @peterhuene figure out what's wrong with fdstat in a subsequent PR. But for now, I'll add a comment uncommenting the problematic lines. |
So it looks like it is passing Windows CI with the uncommented lines. Perhaps the other fix to properly close the handles before unlinking was what actually resolved the issue? I think we can leave it uncommented and remove the preceding comments about the lines being a problem. I'll go ahead with a review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Just some minor feedback before we merge.
Some(code) => { | ||
debug!("path_link at fs::hard_link error code={:?}", code); | ||
match code as u32 { | ||
// TODO is this needed at all???? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this TODO comment actionable or can it be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm removing this mapping, because there is no clear reason why it's needed, just as in #1359.
Absolutely no idea. Perhaps some cleanup I did after removing the fdstats interfered. Anyway, I'm happy that this mysterious failure is gone. I will push out the review changes in several steps. I'm still unsure about point 2 in non-strictness:
Should I correct this in the error mappings or do we prefer to avoid the extra syscall? |
I think we should be fine either way. We should be fine with an additional syscall since we already do that in |
@peterhuene and what do you think? |
I'm 👍 on what you now have. |
Awesome! Then, unless anything comes up, I'm merging the PR tomorrow evening CET. |
This is probably the last missing syscall for Windows!
This PR implements
path_link
for Windows and adds a non-strict version of thepath_link
integration test.I'm unsure about the error handling in
path_link
. MSDN doesn't say much about possible error codes for eitherCreateHardLinkA
orCreateSymbolicLinkA
. I mostly copied over the error conversion frompath_symlink
, but I'm not sure if it's correct. In particular, it's unclear to me what the purpose ofstrip_trailing_slashes_and_concatenate
is.path_symlink
will now also detect an attempt to create a dangling symlink and returnENOTSUP
. (is this the correct return code)?Currently the non-strictness of the test consists of:
subdir
,subdir2
,subdir3
for each test stage. This is due to the fact Windows will not remove the directory and won't allow to create a directory with the same name until the previous one has been deleted. I don't see any way of circumventing it, because the application may still try to access the directory through the unclosed file descriptor.path_link
will returnEACCES
instead ofEPERM
when trying to create a link to a subdirectory. This violates the POSIX spec. We could manually check if the source path is a directory in case ofERROR_ACCESS_DENIED
but this would cost us an extra syscall.ENOTSUP
, but this doesn't make much sense while 1&2 are an issue.Let me know what you think.
Btw. @kubkon, according to this stackoverflow post Mac OS X 10.5+ permits hard links to directories, which our tests expect to fail.
Notes about links and symlinks under Windows:
SeCreateSymbolicLinkPrivilege
). On Windows 10 this requirement may be removed, but this requires enabling developer modefoo -> bar
and later, a directorybar
is created. Then:cd foo
succeeds and the directory view is the same when access either directly or through the symlinkcd foo
fails withThe directory name is invalid