]> Cypherpunks repositories - gostls13.git/commit
go/types: don't write during sanitizeInfo if nothing has changed
authorRob Findley <rfindley@google.com>
Fri, 19 Feb 2021 22:37:17 +0000 (17:37 -0500)
committerRobert Findley <rfindley@google.com>
Fri, 19 Feb 2021 23:22:33 +0000 (23:22 +0000)
commit26713b5fefc158feb1f0f3d5d30627de226f7668
tree2ec28ad88cb4b0a527a48fb4daa0c06cf15ababe
parent9a99515c8f1febe39151a80b2088d0d6fdc55ca2
go/types: don't write during sanitizeInfo if nothing has changed

In its final phase, the typechecker walks the types it produces to
ensure that no unexpanded type instances leak through the API. However,
this also walks shared types (such as those in the universe scope),
resulting in a potential data race during concurrent typechecking
passes.

Fix this by being careful not to write if nothing needs to be changed.
Since any shared types should already be sanitized, this should
eliminate data races.

For #44434

Change-Id: Iadb2e78863efe0e974e69a00e255f26cfaf9386a
Reviewed-on: https://go-review.googlesource.com/c/go/+/294411
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
src/go/types/sanitize.go