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/link: build, run and test frequently fails to complete #40445

Open
GKempsell opened this issue Jul 28, 2020 · 5 comments
Open

cmd/link: build, run and test frequently fails to complete #40445

GKempsell opened this issue Jul 28, 2020 · 5 comments
Milestone

Comments

@GKempsell
Copy link

@GKempsell GKempsell commented Jul 28, 2020

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

$ go version
go version go1.14.6 windows/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\guy.kempsell\AppData\Local\go-build
set GOENV=C:\Users\guy.kempsell\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=**redacted**
set GONOSUMDB=**redacted**
set GOOS=windows
set GOPATH=**redacted**
set GOPRIVATE=**redacted**
set GOPROXY=direct
set GOROOT=C:\Users\guy.kempsell\sdk\go1.14.6
set GOSUMDB=off
set GOTMPDIR=
set GOTOOLDIR=C:\Users\guy.kempsell\sdk\go1.14.6\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\**redacted**\**redacted**\**redacted**\src\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\GUY~1.KEM\AppData\Local\Temp\go-build260781202=/tmp/go-build -gno-record-gcc-switches

What did you do?

Updated to latest version of Go, although issue presented on 1.14.4 first.
Opened a project in Intellij IDEA that was working on Go 1.13 and tried to Run/Debug/Test.
Also tried Goland,VSCode and go cmds from the terminal. All ended with the same result.

What did you expect to see?

The application compiling and running correctly.
Or
Tests running correctly.

What did you see instead?

Frequent non-completion of compile process for both Run and Debug
Test stuck at initialising stage and not completing.

Additional Context

While I can repeat this pretty much every time with some existing projects, it is hard to do so with a fresh project.

The problem will occur 9 times out of 10 and there doesn't appear to be a consistent way of getting round it. Occasionally rerunning will be enough for it to work, sometimes closing and reopening the IDE will help; but more often than not nothing works.

After doing a bit of research I came across this issue: census-instrumentation/opencensus-go#1200

Which pointed me to the fact that calls to go get were effectively timing out, but updating Git resolved this.

I then tried go build -x to get additional output and it appears to be stuck at this step:

"C:\\Users\\guy.kempsell\\sdk\\go1.14.6\\pkg\\tool\\windows_amd64\\link.exe" -o "$WORK\\b001\\exe\\a.out.exe" -importcfg "$WORK\\b001\\importcfg.link" -buildmode=exe -buildid=_MkyF9LK9jUjX681GePM/clZjGxyzEU7znLXb1E2P/DcgycDdsw9oELtDtmgqC/_MkyF9LK9jUjX681GePM -extld=gcc "C:\\Users\\guy.kempsell\\AppData\\Local\\go-build\\02\\02244c9f2d6b3361c85447f0b49ca91dd8640f827dfda53b688b271ca3be44e5-d"

@randall77
Copy link
Contributor

@randall77 randall77 commented Jul 28, 2020

Looks like it hung in the linker.
If you can reproduce, can you try to attach a debugger to that process and get a backtrace?
@thanm @cherrymui

@cagedmantis cagedmantis added this to the Backlog milestone Jul 28, 2020
@cagedmantis cagedmantis changed the title cmd/go: build, run and test frequently fails to complete cmd/link: build, run and test frequently fails to complete Jul 28, 2020
@alexbrainman
Copy link
Member

@alexbrainman alexbrainman commented Jul 29, 2020

I also have some Go build tools hanging on my machine - see #36492. @GKempsell perhaps you have the same bug. Try disabling preemption - that fixes #36492 problem. I only know how to disable preemption by changing Go runtime source code. Perhaps there is an easier way.

Alex

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Jul 29, 2020

how to disable preemption

You can set the environment variable GODEBUG=asyncpreemptoff=1.

@GKempsell
Copy link
Author

@GKempsell GKempsell commented Jul 30, 2020

Sorry for delay in coming back on this. Frustratingly, since you asked for the additional trace I've been unable to replicate the issue. I've gone from 95%+ replication success rate to 0%.

I haven't made any additional environment changes; I didn't even get round to trying with preempt turned off. So I doubt the issue has gone away permanently.

I guess I'll just have to keep an eye on it and if I do manage to replicate it again collect the trace information and send it over.

@alexbrainman
Copy link
Member

@alexbrainman alexbrainman commented Jul 31, 2020

You can set the environment variable GODEBUG=asyncpreemptoff=1.

Thank you, @cherrymui. Indeed that worked here.

Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.