-
Notifications
You must be signed in to change notification settings - Fork 17.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
path/filepath: Clean() incorrect trunc for volume-guid paths on Windows #30307
Comments
I added the requested label and NeedsInvestigation temporarily. |
This does seem to have been introduced by https://golang.org/cl/137055 for #27991. I don't understand the fix. The issue says that Given that this broke something, we should probably just roll it back and consider trying again for 1.13. |
Change https://golang.org/cl/163077 mentions this issue: |
I sent https://golang.org/cl/163077 but I don't really know if it's right. It is, at least, likely to be safe. |
Thanks @ianlancetaylor. I'm happy to try and figure out the right fix in conjunction with yourself and @alexbrainman for 1.13 if you would like. However, at RC1 of 1.12, I tend to agree that reverting the previous fix is probably the safest bet at this stage rather than trying to put a potentially faulty fix in. I believe you are correct that a "traditional" UNC-style path For volume-guid paths, the rule is, somewhat annoyingly, but hey - I didn't create this API!, slightly different. It stems from this sentence in https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-volume: So I believe (although haven't done full validation of this), the following should be the expected behaviour when calling
The one marked * is where I'm not entirely sure as there's some ambiguity reading the documentation, but is certainly what golang 1.11 does, and does not appear to have any issues I am aware of. The way I read the docs is that it's referring to when it's "just" a volume-guid style path, without any further relative paths added - ie just the |
Change https://golang.org/cl/163078 mentions this issue: |
@ianlancetaylor sorry for incomplete fix. Maybe changing method's documentation will be helpful in addiction to revert? I believe that current description is not correct, because of it some kind of misunderstanding and wrong expectations is possible. |
It is not obvious to me that the documentation is wrong. Perhaps |
Revert CL 137055, which changed Clean("\\somepath\dir\") to return "\\somepath\dir" on Windows. It's not entirely clear this is correct, as this path is really "\\server\share\", and as such the trailing slash may be the path on that share, much like "C:\". In any case, the change broke existing code, so roll it back for now and rethink for 1.13. Updates golang#27791 Fixes golang#30307 Change-Id: I69200b1efe38bdb6d452b744582a2bfbb3acbcec Reviewed-on: https://go-review.googlesource.com/c/163077 Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Emmanuel Odeke <[email protected]>
Thank you @ianlancetaylor for reverting promptly - sounds like the safest option. I will think about what to do here, and report back. Alex |
@alexbrainman Hey Alex - am I interpreting gerrit correctly and the reversion didn't make into go 1.12 released yesterday? https://go-review.googlesource.com/c/go/+/163078 still shows active. So I guess I have to wait for 1.12.1? Thanks. |
…lean bug" Revert CL 137055, which changed Clean("\\somepath\dir\") to return "\\somepath\dir" on Windows. It's not entirely clear this is correct, as this path is really "\\server\share\", and as such the trailing slash may be the path on that share, much like "C:\". In any case, the change broke existing code, so roll it back for now and rethink for 1.13. Updates #27791 Updates #30307 Change-Id: I69200b1efe38bdb6d452b744582a2bfbb3acbcec Reviewed-on: https://go-review.googlesource.com/c/163077 Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Emmanuel Odeke <[email protected]> (cherry picked from commit 153c0da) Reviewed-on: https://go-review.googlesource.com/c/163078 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
I think you are correct. There were 2 CLs merged - none of them made to go1.12. https://golang.org/cl/163077 is merged to master branch. And https://go-review.googlesource.com/c/go/+/163078 is merged to release-branch.go1.12 branch. There are 3 commits (including CL 163078) on top of go1.12 tag on that branch at this moment. That branch will be used to make go1.12.1. Alex |
We still need to merge fix for #27791 (originally it was fixed by https://golang.org/cl/137055 but then reversed). This time we need to make sure that fix for #27791 does not break paths that start with We can just adjust filepath.Clean carefully enough, so not to break volume-guid paths (we will still need new test for filepath.Clean( Alternatively, we could make sure that everything in path/filepath and os package handles volume-guid path first, and then fix #27791. I was considering what is involved in doing the latter, and I think it is quite involved. If we are to handle all non-DOS paths. we would have to handle (see https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file for details):
Below are some random questions / issues I can think of in this area. There will be many more, like this. What would VolumeName return for paths starting with
... probably many others, that I did not considered. VolumeName was originally introduced to handle relative paths. But none of And relative path can only start with "drive letter", like C: or D:, so VolumeName function name is wrong now - it should have being called DriveLetter or something. There are many functions in path/filepath package that needs to be fixed, if we are to support paths starting with We also have many non-exported functions in os package (like isAbs, and many others), that needs to be fixed too. A lot of work. Maybe we could move all current implementation into internal package to avoid duplication. I just submitted fix to make Readlink( But, if we are to support paths, like The CL will be released in go1.13. Maybe we should adjust my CL before go1.13 is released to prevent future compatibility problems. Both But paths starting with Same. Both Paths starting with Path like So should we just make small change in filepath.Clean, or should we make all code in path/filepath and os handle paths like /cc @bradfitz and @mattn for their opinion. Alex |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, and is a change in behaviour from 1.11.x
What operating system and processor architecture are you using (
go env
)?go env
Output@alexbrainman
This is the root cause of failures on Windows for upgrading github.com/moby/moby to golang 1.12. (See moby/moby#38404).
The cause appears to be the fix for #27791: d1f7470
In the MSDN documentation for "volume-guid"-style naming, Windows should have a trailing backslash (https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-volume). The specific quote is
To simplify demonstration of the issue, run this test code on golang 1.11.5 and 1.12RC1 (or 1.12Beta)
On go 1.11.5
On go 1.12RC1
Specifically, the trailing backslash is now omitted making an invalid filepath following the MSDN documentation.
The text was updated successfully, but these errors were encountered: