]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix false positive deadlock when using runtime.Goexit
authorDmitriy Vyukov <dvyukov@google.com>
Tue, 5 Mar 2013 07:40:17 +0000 (09:40 +0200)
committerDmitriy Vyukov <dvyukov@google.com>
Tue, 5 Mar 2013 07:40:17 +0000 (09:40 +0200)
Fixes #4893.
Actually it's fixed by cl/7314062 (improved scheduler),
just submitting the test.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7422054

src/pkg/runtime/crash_test.go

index 5f84cb5a2fbed86501c719fa2fc8f783237ae3c8..80549a50549d594d1904f22e34c15d9909f2fe61 100644 (file)
@@ -91,6 +91,14 @@ func TestLockedDeadlock2(t *testing.T) {
        testDeadlock(t, lockedDeadlockSource2)
 }
 
+func TestGoexitDeadlock(t *testing.T) {
+       got := executeTest(t, goexitDeadlockSource, nil)
+       want := ""
+       if got != want {
+               t.Fatalf("expected %q, but got %q", want, got)
+       }
+}
+
 const crashSource = `
 package main
 
@@ -175,3 +183,21 @@ func main() {
        select {}
 }
 `
+
+const goexitDeadlockSource = `
+package main
+import (
+      "runtime"
+)
+
+func F() {
+      for i := 0; i < 10; i++ {
+      }
+}
+
+func main() {
+      go F()
+      go F()
+      runtime.Goexit()
+}
+`