mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: fix GOMAXPROCS vs garbage collection bug
Fixes #1715. R=golang-dev, rsc1, rsc CC=golang-dev https://golang.org/cl/4434053
This commit is contained in:
parent
bad5673c8f
commit
29d78f1243
2 changed files with 38 additions and 0 deletions
32
src/pkg/runtime/proc_test.go
Normal file
32
src/pkg/runtime/proc_test.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package runtime_test
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func perpetuumMobile() {
|
||||
go perpetuumMobile()
|
||||
}
|
||||
|
||||
func TestStopTheWorldDeadlock(t *testing.T) {
|
||||
runtime.GOMAXPROCS(3)
|
||||
compl := make(chan int, 1)
|
||||
go func() {
|
||||
for i := 0; i != 1000; i += 1 {
|
||||
runtime.GC()
|
||||
}
|
||||
compl <- 0
|
||||
}()
|
||||
go func() {
|
||||
for i := 0; i != 1000; i += 1 {
|
||||
runtime.GOMAXPROCS(3)
|
||||
}
|
||||
}()
|
||||
go perpetuumMobile()
|
||||
<-compl
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue