diff options
Diffstat (limited to 'src/pkg/runtime/crash_test.go')
| -rw-r--r-- | src/pkg/runtime/crash_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/pkg/runtime/crash_test.go b/src/pkg/runtime/crash_test.go index 7ea1b6b61a..e07810bb1d 100644 --- a/src/pkg/runtime/crash_test.go +++ b/src/pkg/runtime/crash_test.go @@ -125,6 +125,14 @@ func TestStackOverflow(t *testing.T) { } } +func TestThreadExhaustion(t *testing.T) { + output := executeTest(t, threadExhaustionSource, nil) + want := "runtime: program exceeds 10-thread limit\nfatal error: thread exhaustion" + if !strings.HasPrefix(output, want) { + t.Fatalf("output does not start with %q:\n%s", want, output) + } +} + const crashSource = ` package main @@ -243,3 +251,25 @@ func f(x []byte) byte { return x[0] + f(buf[:]) } ` + +const threadExhaustionSource = ` +package main + +import ( + "runtime" + "runtime/debug" +) + +func main() { + debug.SetMaxThreads(10) + c := make(chan int) + for i := 0; i < 100; i++ { + go func() { + runtime.LockOSThread() + c <- 0 + select{} + }() + <-c + } +} +` |
