-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
os: Lstat
on darwin
sometimes fails to expand symlinks in paths with trailing slashes
#59586
Comments
On I suspect that this is a bug in the macOS |
|
Notably, POSIX requires:
|
Change https://go.dev/cl/484216 mentions this issue: |
The list_goroot_symlink test relies on fsys.Walk (and ultimately syscall.Lstat) conforming to POSIX pathname resolution semantics. POSIX requires that symlinks ending in a slash be fully resolved, but it appears that lstat in current darwin kernels does not fully resolve the last pathname component when it is a symlink to a symlink. For #59586. For #35678. Change-Id: I37526f012ba94fa1796b33109a41c3226c967d3e Reviewed-on: https://go-review.googlesource.com/c/go/+/484216 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Bypass: Bryan Mills <bcmills@google.com>
A C reproducer:
|
Change https://go.dev/cl/484395 mentions this issue: |
Looks like only |
The "double link with slash" test is skipped on darwin due to an apparent kernel / libc bug. If the bug is present on other platforms too, I'd like to know about it. For #59586. Change-Id: I4bdd6a80a3ed7b0960ea6da30f91a655f317d512 Reviewed-on: https://go-review.googlesource.com/c/go/+/484395 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Since this appears to be a kernel bug and we don't have a pressing need to work around it at the moment, moving to the Unplanned milestone. If and when Apple fixes the macOS bug, we can remove the test-skips that refer to this issue and close it. |
Here's a shell reproducer:
The As @bcmills mentioned above, resolving the symlink is required by POSIX, and I have confirmed that the bug is not present on FreeBSD or Linux, so this is not a case of "everyone ignores this POSIX detail". |
Change https://go.dev/cl/484755 mentions this issue: |
For #59586. Change-Id: I092f7a4abce1074b8eef64a3ecf9fc187914709b Reviewed-on: https://go-review.googlesource.com/c/go/+/484755 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Bypass: Bryan Mills <bcmills@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Extend
path/filepath.TestWalkSymlinkRoot
with the following test cases, inspired bycmd/go.TestScript/list_goroot_symlink
:What did you expect to see?
The additional tests should pass.
Per POSIX pathname resolution, pathname resolution should proceed as:
td
variable are resolved, giving a path of the form$td/linklink/
(where$td
is fully-resolved).linklink
component is/
.$td/linklink
resolves to$td/link
, so$td/link
should be prefixed to/
, giving$td/link/
for the next step.$td/link/
has a trailing slash and the path includes unresolved components, pathname resolution is not yet complete.$td/link
resolves to$td/dir
, so$td/dir
should be prefixed to/
, giving$td/dir/
, which is fully resolved.What did you see instead?
The additional tests pass on
linux
, consistent with POSIX pathname resolution.However, the
linklink
test fails on adarwin-amd64-longtest
gomote instance:(CC @golang/darwin)
The text was updated successfully, but these errors were encountered: