Skip to content

Commit 3672a09

Browse files
felixgeadonovan
authored andcommitted
runtime/debug: update SetCrashOutput example to not pass parent env vars
Fixes #73490 Change-Id: I500fa73f4215c7f490779f53c1c2c0d775f51a95 Reviewed-on: https://go-review.googlesource.com/c/go/+/667775 Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent 3452d80 commit 3672a09

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/runtime/debug/example_monitor_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ func monitor() {
8484
log.Fatal(err)
8585
}
8686
cmd := exec.Command(exe, "-test.run=^ExampleSetCrashOutput_monitor$")
87-
cmd.Env = append(os.Environ(), monitorVar+"=1")
87+
// Be selective in which variables we allow the child to inherit.
88+
// Depending on the application, some may be necessary,
89+
// while others (e.g. GOGC, GOMEMLIMIT) may be harmful; see #73490.
90+
cmd.Env = []string{monitorVar + "=1"}
8891
cmd.Stderr = os.Stderr
8992
cmd.Stdout = os.Stderr
9093
pipe, err := cmd.StdinPipe()

0 commit comments

Comments
 (0)