]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.19] cmd/go: avoid registering AtExit handlers in tests
authorBryan C. Mills <bcmills@google.com>
Wed, 24 Aug 2022 13:45:18 +0000 (09:45 -0400)
committerHeschi Kreinick <heschi@google.com>
Mon, 29 Aug 2022 19:15:41 +0000 (19:15 +0000)
commit4b1c16cc4527de7539c36dd51f4686663bd644a0
treee12a6c2a63a46fff17c27242537102ecd642a66e
parent2553a09e31d1a87072c7a68e352cd404df95b23d
[release-branch.go1.19] cmd/go: avoid registering AtExit handlers in tests

Ever since 'go build' was added (in CL 5483069), it has used an atexit
handler to clean up working directories.

CL 154109 introduced 'cc' command to the script test framework that
called Init on a builder once per invocation. Unfortunately, since
base.AtExit is unsynchronized, the Init added there caused any script
that invokes that command to be unsafe for concurrent use.

This change fixes the race by having the 'cc' command pass in its
working directory instead of allowing the Builder to allocate one.
Following modern Go best practices, it also replaces the in-place Init
method (which is prone to typestate and aliasing bugs) with a
NewBuilder constructor function.

Updates #54423.
Fixes #54637.

Change-Id: I8fc2127a7d877bb39a1174e398736bb51d03d4d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/425205
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
(cherry picked from commit d5aa088d822bc8ef3ceb80c20184f40fcb9b8d2e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/425207
src/cmd/go/internal/envcmd/env.go
src/cmd/go/internal/list/list.go
src/cmd/go/internal/run/run.go
src/cmd/go/internal/test/test.go
src/cmd/go/internal/vet/vet.go
src/cmd/go/internal/work/action.go
src/cmd/go/internal/work/build.go
src/cmd/go/script_test.go