LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package time_test | 5 package time_test |
6 | 6 |
7 import ( | 7 import ( |
8 "errors" | 8 "errors" |
9 "fmt" | 9 "fmt" |
10 "runtime" | 10 "runtime" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // OK | 307 // OK |
308 } | 308 } |
309 const neg = Duration(-1 << 63) | 309 const neg = Duration(-1 << 63) |
310 select { | 310 select { |
311 case <-After(neg): | 311 case <-After(neg): |
312 // OK | 312 // OK |
313 case <-After(timeout): | 313 case <-After(timeout): |
314 t.Fatalf("negative timeout didn't fire") | 314 t.Fatalf("negative timeout didn't fire") |
315 } | 315 } |
316 } | 316 } |
| 317 |
| 318 // Test that a panic while deleting a timer does not leave |
| 319 // the timers mutex held, deadlocking a ticker.Stop in a defer. |
| 320 func TestIssue5745(t *testing.T) { |
| 321 ticker := NewTicker(Hour) |
| 322 defer func() { |
| 323 // would deadlock here before the fix due to |
| 324 // lock taken before the segfault. |
| 325 ticker.Stop() |
| 326 |
| 327 if r := recover(); r == nil { |
| 328 t.Error("Expected panic, but none happened.") |
| 329 } |
| 330 }() |
| 331 |
| 332 // cause a panic due to a segfault |
| 333 var timer *Timer |
| 334 timer.Stop() |
| 335 t.Error("Should be unreachable.") |
| 336 } |
LEFT | RIGHT |