This libgo patch limits the default value of GOMAXPROCS to 32 on
32-bit systems.  Otherwise we can easily run out of stack space for
threads.  The user can still override by setting GOMAXPROCS.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
a339c239a7ed8af25eb612ea4ceb5d975528b951
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 27f4ce342e5..9916b02c57f 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-c94637ad6fd38d4814fb02d094a1a73f19323d71
+3e46519cee5c916a9b39480fbac13f4ffc6a93b0
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go
index c0e85773098..e3f934ae7bd 100644
--- a/libgo/go/runtime/proc.go
+++ b/libgo/go/runtime/proc.go
@@ -563,6 +563,14 @@ func schedinit() {
 
        sched.lastpoll = uint64(nanotime())
        procs := ncpu
+
+       // In 32-bit mode, we can burn a lot of memory on thread stacks.
+       // Try to avoid this by limiting the number of threads we run
+       // by default.
+       if sys.PtrSize == 4 && procs > 32 {
+               procs = 32
+       }
+
        if n, ok := atoi32(gogetenv("GOMAXPROCS")); ok && n > 0 {
                procs = n
        }

Reply via email to