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

cmd/go: build/program failed to run on invalid symlink in ignored directory #53387

Closed
shuLhan opened this issue Jun 15, 2022 · 4 comments
Closed
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@shuLhan
Copy link
Contributor

shuLhan commented Jun 15, 2022

What version of Go are you using (go version)?

$ go version
go version devel go1.19-2a78e8afc0 Wed Jun 15 00:06:24 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

No.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/home/ms/go/bin"
GOCACHE="/home/ms/.cache/go-build"
GOENV="/home/ms/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ms/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ms/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/ms/opt/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/ms/opt/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.19-bc01cb278a Sun Jun 12 11:30:23 2022 +0700"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/home/ms/go/src/github.com/shuLhan/sandbox-go/go119-build/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1693274605=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Create hidden directory with invalid symlinks inside it,

10:22:10 ~/go/src/github.com/shuLhan/sandbox-go/go119-build
(ins) 1 $ tree -a
.
├── go.mod
├── .hidden
│   └── notexist -> ../notexist
└── main.go

1 directory, 3 files

 10:22:12 ~/go/src/github.com/shuLhan/sandbox-go/go119-build
(ins) 1 $ cat main.go
package main

func main() {
        println("hello 1.19")
}

Run go build or program that build with this Go version.

What did you expect to see?

Source code compiled and build successfully.

What did you see instead?

10:24:55 ~/go/src/github.com/shuLhan/sandbox-go/go119-build
(ins) 1 $ go build .
stat /home/ms/go/src/github.com/shuLhan/sandbox-go/go119-build/.hidden/notexist: no such file or directory

Use case when the program build using this Go version (in this case fieldalignment from x/tools) with directory start with _ and invalid symlink,

10:28:28 ~/go/src/github.com/shuLhan/sandbox-go/go119-build
(ins) 1 $ fieldalignment .
-: stat /home/ms/go/src/github.com/shuLhan/sandbox-go/go119-build/.hidden/notexist: no such file or directory
fieldalignment: error during loading

Notes

A quick bisect show that commit 899f0a2 (#53290) is the cause.

 11:06:11 ~/go/src/github.com/shuLhan/sandbox-go/go119-build
(ins) 1 $ go version
go version devel go1.19-899f0a29c7 Wed Jun 8 16:53:29 2022 +0000 linux/amd64

 11:06:11 ~/go/src/github.com/shuLhan/sandbox-go/go119-build
(ins) 1 $ go run .
stat /home/ms/go/src/github.com/shuLhan/sandbox-go/go119-build/.hidden/notexist: no such file or directory

 11:06:15 ~/go/src/github.com/shuLhan/sandbox-go/go119-build
(ins) 1 $ GODEBUG=goindex=0 go run .
hello 1.19
@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Jun 15, 2022
@seankhliao
Copy link
Member

cc @matloob

@bradfitz
Copy link
Contributor

Lest anybody else file dups like I did (#53421) after searching open issues for "emacs" and "dangling", the thing that bit me was Emacs lock files, which apparently I had a ton of.

@bcmills
Copy link
Member

bcmills commented Jun 17, 2022

This should be fixed by CL 412394 / CL 412779.

@bcmills
Copy link
Member

bcmills commented Jun 22, 2022

Should be fixed at head — please let us know if that is not the case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
Development

No branches or pull requests

6 participants