if (n <= 0)
n = ret;
runtime·gomaxprocs = n;
+ if (runtime·gcwaiting != 0) {
+ if (runtime·sched.mcpumax != 1)
+ runtime·throw("invalid runtime·sched.mcpumax during gc");
+ schedunlock();
+ return ret;
+ }
runtime·sched.mcpumax = n;
// handle fewer procs?
if(runtime·sched.mcpu > runtime·sched.mcpumax) {
--- /dev/null
+// 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
+}