bazel-contrib / bazel-contrib/rules_go

Fix leaks in /tmp

Open
#3,587 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.5k
Forks
760
Avg merge
1d 11h
Merged PRs (30d)
12

Description

In a recent discussion with my team, we discovered that our shared dev environment is filled with `/tmp/rules_go_work-XXXXX` not being clean up.

![image](https://github.com/bazelbuild/rules_go/assets/26684313/f5057c18-88fb-4e0b-b2d0-b140b2059ecf)

I think this is because we are currently calling the cleanup function for this tmpdir in a `defer()` statement, which will not be executed if somewhere down the stack `log.Fatalf()` is called.

We should ensure that either `fatal` is only used in the outer `main()` func, or we have a reliable cleanup that survives `os.Exit` and `log.Fatal`

Contributor guide

Open the contributing guide

Research direction

Start by tracing the tmpdir cleanup function and the call sites that use fatal, especially the outer main() entry point mentioned in the issue. Confirm the cleanup behavior on fatal exits and ensure the relevant exit paths no longer leave /tmp/rules_go_work-XXXXX directories behind.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.