Navigation Menu

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: install/build doesn't remove temporary files when aborted #25808

Open
aykevl opened this issue Jun 9, 2018 · 6 comments
Open

cmd/go: install/build doesn't remove temporary files when aborted #25808

aykevl opened this issue Jun 9, 2018 · 6 comments
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@aykevl
Copy link

aykevl commented Jun 9, 2018

Go version: go1.10 linux/amd64

I've noticed go build and go install don't remove temporary files in /tmp/go-* when aborted with Ctrl-C.
This is an issue with big programs (binary size ~1GB due to linking with a huge C/C++ library), because late in the linking process an intermediary file is created as big as the output file (probably it's the output file itself) that just stays in /tmp on a tmpfs. Aborting a few times at this stage in the build will quickly fill the RAM on a regular computer until the next reboot (or until manually removing all temporary files).

It would be nice if the Go toolchain would remove it's own temporary files when aborted.

@agnivade agnivade changed the title Go install doesn't remove temporary files when aborted cmd/go: install/build doesn't remove temporary files when aborted Jun 10, 2018
@agnivade agnivade added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 10, 2018
@agnivade agnivade added this to the Go1.12 milestone Jun 10, 2018
@agnivade
Copy link
Contributor

I believe tmpfs will swap out to disk when memory is too low, but that's an orthogonal issue.

/cc @ianlancetaylor , @rsc

@bcmills bcmills added the GoCommand cmd/go label Nov 15, 2018
@bcmills bcmills modified the milestones: Go1.12, Go1.13 Nov 15, 2018
@bcmills
Copy link
Contributor

bcmills commented Nov 15, 2018

I can think of at least two ways we could address this:

  1. Register temporary directories with cmd/go/internal/base for deletion when base.Exit is called.
  2. Plumb through some sort of cancellation mechanism (perhaps a context.Context in the cmd/go/internal/base package?) so that functions can return (and execute defer calls for cleanup) on interrupt.

@rsc
Copy link
Contributor

rsc commented Nov 20, 2018

Context is inappropriate here. We have context - the whole binary.
Registering temporary directories would be fine.

@rsc
Copy link
Contributor

rsc commented Nov 20, 2018

(Even better, make one temporary directory and put all the others under it and then there's just one tree to remove.)

@szmcdull
Copy link

szmcdull commented Feb 8, 2023

what is blocking this issue from being resolved

@ianlancetaylor
Copy link
Contributor

@szmcdull It hasn't been a high enough priority for anybody to work on it. Go is an open source project; would you be interested in taking a look and sending a fix? Thanks.

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

No branches or pull requests

7 participants