Skip to content

cmd/link: does not clean up host link inputs #24704

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

Closed
ncw opened this issue Apr 5, 2018 · 6 comments
Closed

cmd/link: does not clean up host link inputs #24704

ncw opened this issue Apr 5, 2018 · 6 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Milestone

Comments

@ncw
Copy link
Contributor

ncw commented Apr 5, 2018

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

go version go1.10.1 windows/amd64

Does this issue reproduce with the latest release?

Yes. Haven't tried tip.

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

I'm running this on Windows 2016 Server, but I've see the same issue on Windows 7 too.

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Administrator\go
set GORACE=
set GOROOT=C:\tools\go
set GOTMPDIR=
set GOTOOLDIR=C:\tools\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
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 -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\2\go-build231439986=/tmp/go-build -gno
-record-gcc-switches

What did you do?

Compile this very simple cgo program - a directory called go-link-XXXXX is left behind in %TEMP%.

image

Programs which do not use cgo leave nothing behind in %TEMP%.

What did you expect to see?

I expected go to clean up after itself.

What did you see instead?

A left over directory in %TEMP%. Inside it is a single file

image

I noticed this because I left my machine running go test in a loop overnight and it filled the disk up!

@ALTree ALTree added OS-Windows NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 5, 2018
@ALTree ALTree added this to the Go1.11 milestone Apr 5, 2018
@rsc
Copy link
Contributor

rsc commented Apr 5, 2018

The relevant code is in src/cmd/link/internal/ld/lib.go's hostlinksetup, which does AtExit(rmtemp), and rmtemp in turn does os.RemoveAll of the temp dir. The next step is to find out why RemoveAll is not removing all. Probably Windows thinks some process still has go.o open and refuses to remove it. I hope that process is cmd/link - that is, I hope we just forgot to close the file - because that would be an easy fix.

@rsc rsc changed the title cmd/cgo: windows compiles using cgo leave behind files in %TEMP% cmd/link: does not clean up host link inputs Apr 5, 2018
@rsc rsc added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 5, 2018
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 5, 2018
@alexbrainman
Copy link
Member

@ncw my favorite type of bug, thank you. :-) I will try to debug this when I have time.

Alex

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/113935 mentions this issue: cmd/link: close go.o before deleting it

@laboger
Copy link
Contributor

laboger commented May 23, 2018

The new test added here fails on linux/ppc64 (works fine on linux/ppc64le) since full linker support was never added for linux/ppc64 and cgo doesn't work there. The test should be skipped for linux/ppc64.

@ncw
Copy link
Contributor Author

ncw commented May 23, 2018

Thanks for fixing this @alexbrainman - you are the windows wizard :-)

@alexbrainman
Copy link
Member

The new test added here fails on linux/ppc64 (works fine on linux/ppc64le) since full linker support was never added for linux/ppc64 and cgo doesn't work there. The test should be skipped for linux/ppc64.

This is fixed by CL 114235 now. Sorry for breaking it, but there are no try-bots configured as no-cgo.

Alex

@golang golang locked and limited conversation to collaborators May 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Projects
None yet
Development

No branches or pull requests

6 participants