From: Michael Pratt Date: Wed, 4 Aug 2021 20:07:47 +0000 (-0400) Subject: runtime: avoid loop variable capture in test X-Git-Tag: go1.18beta1~1356 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b2c04f0d48234765ce37bbb178bd174f3857929a;p=gostls13.git runtime: avoid loop variable capture in test In TestSegv, the t.Run closure captures the loop variable 'test'. Since the subtest calls t.Parallel, the parent test is allowed to keep running, changing the loop variable and thus changing the value of 'test' in the subtest. Change-Id: I021ddc50304de08a341e6ffe486aa54e573d3b94 Reviewed-on: https://go-review.googlesource.com/c/go/+/339911 Trust: Michael Pratt Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Austin Clements Reviewed-by: Cherry Mui --- diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go index 5729942cee..ce7bed920f 100644 --- a/src/runtime/crash_cgo_test.go +++ b/src/runtime/crash_cgo_test.go @@ -591,6 +591,7 @@ func TestSegv(t *testing.T) { } for _, test := range []string{"Segv", "SegvInCgo"} { + test := test t.Run(test, func(t *testing.T) { t.Parallel() got := runTestProg(t, "testprogcgo", test)