package sys

import "runtime"

const dumpStackBufSizeInit = 4096

func DumpStack() string {
	buf := make([]byte, dumpStackBufSizeInit)
	for {
		n := runtime.Stack(buf, true)
		if n < cap(buf) {
			return string(buf[:n])
		}
		buf = make([]byte, cap(buf)*2)
	}
}

package sys

import "runtime"

func DumpStack() string {
	buf := make([]byte, 1024)
	for runtime.Stack(buf, true) == cap(buf) {
		buf = make([]byte, cap(buf)*2)
	}
	return string(buf)
}

--- 
+++ 
@@ -2,10 +2,15 @@
 
 import "runtime"
 
+const dumpStackBufSizeInit = 4096
+
 func DumpStack() string {
-	buf := make([]byte, 1024)
-	for runtime.Stack(buf, true) == cap(buf) {
+	buf := make([]byte, dumpStackBufSizeInit)
+	for {
+		n := runtime.Stack(buf, true)
+		if n < cap(buf) {
+			return string(buf[:n])
+		}
 		buf = make([]byte, cap(buf)*2)
 	}
-	return string(buf)
 }
sys: Fix DumpStack to return the correct part of the buffer.
