Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(880)

Delta Between Two Patch Sets: src/pkg/time/sleep_test.go

Issue 10373047: code review 10373047: runtime: prevent a panic from leaving the timer mutex held (Closed)
Left Patch Set: Created 10 years, 9 months ago
Right Patch Set: diff -r 166d946fa77f http://code.google.com/p/go Created 10 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/time.goc ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(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
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 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b