]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/debug: update SetCrashOutput example to not pass parent env vars
authorFelix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Thu, 24 Apr 2025 14:38:58 +0000 (16:38 +0200)
committerAlan Donovan <adonovan@google.com>
Thu, 24 Apr 2025 19:01:27 +0000 (12:01 -0700)
Fixes #73490

Change-Id: I500fa73f4215c7f490779f53c1c2c0d775f51a95
Reviewed-on: https://go-review.googlesource.com/c/go/+/667775
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/debug/example_monitor_test.go

index 3b8f4dccd9f05325a8bd40fe9a3c0a4c70cbaec5..ed6757df855d08eab60c336e3d577ae664169868 100644 (file)
@@ -84,7 +84,10 @@ func monitor() {
                log.Fatal(err)
        }
        cmd := exec.Command(exe, "-test.run=^ExampleSetCrashOutput_monitor$")
-       cmd.Env = append(os.Environ(), monitorVar+"=1")
+       // Be selective in which variables we allow the child to inherit.
+       // Depending on the application, some may be necessary,
+       // while others (e.g. GOGC, GOMEMLIMIT) may be harmful; see #73490.
+       cmd.Env = []string{monitorVar + "=1"}
        cmd.Stderr = os.Stderr
        cmd.Stdout = os.Stderr
        pipe, err := cmd.StdinPipe()