aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing.go
diff options
context:
space:
mode:
authorMichał Łowicki <mlowicki@gmail.com>2020-08-23 23:53:04 +0100
committerBryan C. Mills <bcmills@google.com>2020-08-25 18:28:59 +0000
commit00a053bd4b2c19b2d9680f78f4c8657fcc6f1c88 (patch)
tree1d7df20758c884c9f13386d2bdf88800eb89bd67 /src/testing/testing.go
parent8d31ca255bd6b00d04f1673d26110b702e96662b (diff)
downloadgo-00a053bd4b2c19b2d9680f78f4c8657fcc6f1c88.tar.gz
go-00a053bd4b2c19b2d9680f78f4c8657fcc6f1c88.zip
testing: fix Cleanup race with Logf and Errorf
Fixes #40908 Change-Id: I25561a3f18e730a50e6fbf85aa7bd85bf1b73b6e Reviewed-on: https://go-review.googlesource.com/c/go/+/250078 Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/testing/testing.go')
-rw-r--r--src/testing/testing.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go
index 6fc8c4fa9f..bf83df8863 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -860,11 +860,15 @@ func (c *common) Cleanup(f func()) {
c.cleanup = func() {
if oldCleanup != nil {
defer func() {
+ c.mu.Lock()
c.cleanupPc = oldCleanupPc
+ c.mu.Unlock()
oldCleanup()
}()
}
+ c.mu.Lock()
c.cleanupName = callerName(0)
+ c.mu.Unlock()
f()
}
var pc [maxStackLen]uintptr