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 · 4 comments

Comments

Projects
None yet
4 participants
@aykevl

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 from Go install doesn't remove temporary files when aborted to cmd/go: install/build doesn't remove temporary files when aborted Jun 10, 2018

@agnivade agnivade added this to the Go1.12 milestone Jun 10, 2018

@agnivade

This comment has been minimized.

Member

agnivade commented Jun 10, 2018

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 label Nov 15, 2018

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Nov 15, 2018

@bcmills

This comment has been minimized.

Member

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

This comment has been minimized.

Contributor

rsc commented Nov 20, 2018

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

@rsc

This comment has been minimized.

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment