diff options
Diffstat (limited to 'src/pkg/time/sleep_test.go')
-rw-r--r-- | src/pkg/time/sleep_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/pkg/time/sleep_test.go b/src/pkg/time/sleep_test.go index 1322f0611..603adc9b8 100644 --- a/src/pkg/time/sleep_test.go +++ b/src/pkg/time/sleep_test.go @@ -314,3 +314,23 @@ func TestOverflowSleep(t *testing.T) { t.Fatalf("negative timeout didn't fire") } } + +// Test that a panic while deleting a timer does not leave +// the timers mutex held, deadlocking a ticker.Stop in a defer. +func TestIssue5745(t *testing.T) { + ticker := NewTicker(Hour) + defer func() { + // would deadlock here before the fix due to + // lock taken before the segfault. + ticker.Stop() + + if r := recover(); r == nil { + t.Error("Expected panic, but none happened.") + } + }() + + // cause a panic due to a segfault + var timer *Timer + timer.Stop() + t.Error("Should be unreachable.") +} |