diff options
| author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-06 19:49:01 +0000 |
|---|---|---|
| committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-06 19:49:01 +0000 |
| commit | 0ce10ea1348e9afd5d0eec6bca986bfe58bac5ac (patch) | |
| tree | 39530b071991b2326f881b2a30a2d82d6c133fd6 /libgo/go/runtime/debug | |
| parent | 57a8bf1b0c6057ccbacb0cf79eb84d1985c2c1fe (diff) | |
| download | ppe42-gcc-0ce10ea1348e9afd5d0eec6bca986bfe58bac5ac.tar.gz ppe42-gcc-0ce10ea1348e9afd5d0eec6bca986bfe58bac5ac.zip | |
libgo: Update to October 24 version of master library.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204466 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/runtime/debug')
| -rw-r--r-- | libgo/go/runtime/debug/garbage.go | 34 | ||||
| -rw-r--r-- | libgo/go/runtime/debug/stack_test.go | 8 |
2 files changed, 38 insertions, 4 deletions
diff --git a/libgo/go/runtime/debug/garbage.go b/libgo/go/runtime/debug/garbage.go index 8f30264264f..8337d5d5b34 100644 --- a/libgo/go/runtime/debug/garbage.go +++ b/libgo/go/runtime/debug/garbage.go @@ -24,6 +24,8 @@ func readGCStats(*[]time.Duration) func enableGC(bool) bool func setGCPercent(int) int func freeOSMemory() +func setMaxStack(int) int +func setMaxThreads(int) int // ReadGCStats reads statistics about garbage collection into stats. // The number of entries in the pause history is system-dependent; @@ -99,3 +101,35 @@ func SetGCPercent(percent int) int { func FreeOSMemory() { freeOSMemory() } + +// SetMaxStack sets the maximum amount of memory that +// can be used by a single goroutine stack. +// If any goroutine exceeds this limit while growing its stack, +// the program crashes. +// SetMaxStack returns the previous setting. +// The initial setting is 1 GB on 64-bit systems, 250 MB on 32-bit systems. +// +// SetMaxStack is useful mainly for limiting the damage done by +// goroutines that enter an infinite recursion. It only limits future +// stack growth. +func SetMaxStack(bytes int) int { + return setMaxStack(bytes) +} + +// SetMaxThreads sets the maximum number of operating system +// threads that the Go program can use. If it attempts to use more than +// this many, the program crashes. +// SetMaxThreads returns the previous setting. +// The initial setting is 10,000 threads. +// +// The limit controls the number of operating system threads, not the number +// of goroutines. A Go program creates a new thread only when a goroutine +// is ready to run but all the existing threads are blocked in system calls, cgo calls, +// or are locked to other goroutines due to use of runtime.LockOSThread. +// +// SetMaxThreads is useful mainly for limiting the damage done by +// programs that create an unbounded number of threads. The idea is +// to take down the program before it takes down the operating system. +func SetMaxThreads(threads int) int { + return setMaxThreads(threads) +} diff --git a/libgo/go/runtime/debug/stack_test.go b/libgo/go/runtime/debug/stack_test.go index bbd662618fd..263d7155997 100644 --- a/libgo/go/runtime/debug/stack_test.go +++ b/libgo/go/runtime/debug/stack_test.go @@ -49,10 +49,10 @@ func TestStack(t *testing.T) { n++ } } - frame("src/pkg/runtime/debug/stack_test.go", "\t(*T).ptrmethod: return Stack()") - frame("src/pkg/runtime/debug/stack_test.go", "\tT.method: return t.ptrmethod()") - frame("src/pkg/runtime/debug/stack_test.go", "\tTestStack: b := T(0).method()") - frame("src/pkg/testing/testing.go", "") + frame("stack_test.go", "\tmethod.N15_runtime_debug.T: return Stack()") + frame("stack_test.go", "\tmethod.N15_runtime_debug.T: return t.ptrmethod()") + frame("stack_test.go", "\tTestStack: b := T(0).method()") + frame("testing/testing.go", "") } func check(t *testing.T, line, has string) { |

