-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: data race in TestScript #54423
Comments
Change https://go.dev/cl/423535 mentions this issue: |
I'm not sure why the race is just now surfacing, but Since Even better still would be to refactor the |
Oh! I do know why the race is just now surfacing. CL 402596 added a non- I've filed that testing gap as #54630. |
Change https://go.dev/cl/425254 mentions this issue: |
@gopherbot, please backport to go 1.18 and 1.19. This causes a data race in |
Backport issue(s) opened: #54636 (for 1.18), #54637 (for 1.19). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Change https://go.dev/cl/425206 mentions this issue: |
Change https://go.dev/cl/425205 mentions this issue: |
Change https://go.dev/cl/425207 mentions this issue: |
Change https://go.dev/cl/425208 mentions this issue: |
…d use Ever since 'go build' was added (in CL 5483069), it has used an atexit handler to clean up working directories. At some point (prior to CL 95900044), Init was called multiple times per builder, registering potentially many atexit handlers that execute asynchronously and make debugging more difficult. The use of an AtExit handler also makes the Builder (and anything that uses it) prone to races: the base.AtExit API is not designed for concurrent use, but cmd/go is becoming increasingly concurrent over time. The AtExit handler also makes the Builder inappropriate to use within a unit-test, since the handlers do not run during the test function and accumulate over time. This change makes NewBuilder safe for concurrent use by registering the AtExit handler only once (during BuildInit, which was already not safe for concurrent use), and using a sync.Map to store the set of builders that need cleanup in case of an unclean exit. In addition, it causes the test variant of cmd/go to fail if any Builder instance leaks from a clean exit, helping to ensure that functions that create Builders do not leak them indefinitely, especially in tests. Updates #54423. Change-Id: Ia227b15b8fa53c33177c71271d756ac0858feebe Reviewed-on: https://go-review.googlesource.com/c/go/+/425254 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
These tests invoke the system C compiler and linker. Skipping them saves a little over half a second of time in short mode. Updates #54423. Change-Id: I3e8aa7b53c0c91f7d1e001ec2cd5f7b4954de52d Reviewed-on: https://go-review.googlesource.com/c/go/+/425206 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
…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 #54636. 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 d5aa088) Reviewed-on: https://go-review.googlesource.com/c/go/+/425208
…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 d5aa088) Reviewed-on: https://go-review.googlesource.com/c/go/+/425207
…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 golang#54423. Fixes golang#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 d5aa088) Reviewed-on: https://go-review.googlesource.com/c/go/+/425207
From a trybot on https://go.dev/cl/423436: https://storage.googleapis.com/go-build-log/64056b67/linux-amd64-race_b880b74d.log
cmd/go/internal/base.AtExit
is clearly not thread safe, but I'm not sure why this race is just surfacing. That code andt.Parallel
in TestScript both seem to have been there for quite a while.cc @bcmills
The text was updated successfully, but these errors were encountered: