aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/time
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-04-06 14:04:45 -0700
committerIan Lance Taylor <iant@golang.org>2020-04-06 16:37:24 -0700
commit52fa80f853c0b0f623ea9e4c7198e324ce44ff30 (patch)
treee2695726e95b7bd125d52b7bdd315cb0028854fa /libgo/go/time
parent749bd22ddc50b5112e5ed506ffef7249bf8e6fb3 (diff)
downloadgcc-52fa80f853c0b0f623ea9e4c7198e324ce44ff30.zip
gcc-52fa80f853c0b0f623ea9e4c7198e324ce44ff30.tar.gz
gcc-52fa80f853c0b0f623ea9e4c7198e324ce44ff30.tar.bz2
libgo: update to almost the 1.14.2 release
Update to edea4a79e8d7dea2456b688f492c8af33d381dc2 which is likely to be approximately the 1.14.2 release. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/227377
Diffstat (limited to 'libgo/go/time')
-rw-r--r--libgo/go/time/time_test.go40
1 files changed, 24 insertions, 16 deletions
diff --git a/libgo/go/time/time_test.go b/libgo/go/time/time_test.go
index 95998c3..2fc23c4 100644
--- a/libgo/go/time/time_test.go
+++ b/libgo/go/time/time_test.go
@@ -9,7 +9,6 @@ import (
"encoding/gob"
"encoding/json"
"fmt"
- "internal/race"
"math/big"
"math/rand"
"os"
@@ -1393,36 +1392,45 @@ func TestReadFileLimit(t *testing.T) {
}
// Issue 25686: hard crash on concurrent timer access.
+// Issue 37400: panic with "racy use of timers"
// This test deliberately invokes a race condition.
-// We are testing that we don't crash with "fatal error: panic holding locks".
+// We are testing that we don't crash with "fatal error: panic holding locks",
+// and that we also don't panic.
func TestConcurrentTimerReset(t *testing.T) {
- if race.Enabled {
- t.Skip("skipping test under race detector")
- }
-
- // We expect this code to panic rather than crash.
- // Don't worry if it doesn't panic.
- catch := func(i int) {
- if e := recover(); e != nil {
- t.Logf("panic in goroutine %d, as expected, with %q", i, e)
- } else {
- t.Logf("no panic in goroutine %d", i)
- }
+ const goroutines = 8
+ const tries = 1000
+ var wg sync.WaitGroup
+ wg.Add(goroutines)
+ timer := NewTimer(Hour)
+ for i := 0; i < goroutines; i++ {
+ go func(i int) {
+ defer wg.Done()
+ for j := 0; j < tries; j++ {
+ timer.Reset(Hour + Duration(i*j))
+ }
+ }(i)
}
+ wg.Wait()
+}
+// Issue 37400: panic with "racy use of timers".
+func TestConcurrentTimerResetStop(t *testing.T) {
const goroutines = 8
const tries = 1000
var wg sync.WaitGroup
- wg.Add(goroutines)
+ wg.Add(goroutines * 2)
timer := NewTimer(Hour)
for i := 0; i < goroutines; i++ {
go func(i int) {
defer wg.Done()
- defer catch(i)
for j := 0; j < tries; j++ {
timer.Reset(Hour + Duration(i*j))
}
}(i)
+ go func(i int) {
+ defer wg.Done()
+ timer.Stop()
+ }(i)
}
wg.Wait()
}