mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-16 18:30:58 +00:00
control/controlclient: grow goroutine debug buffer as needed
To not allocate 1MB up front on iOS. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
1986d071c3
commit
4a2c3e2a0a
@ -44,8 +44,17 @@ func dumpGoroutinesToURL(c *http.Client, targetURL string) {
|
|||||||
// scrubbedGoroutineDump returns the list of all current goroutines, but with the actual
|
// scrubbedGoroutineDump returns the list of all current goroutines, but with the actual
|
||||||
// values of arguments scrubbed out, lest it contain some private key material.
|
// values of arguments scrubbed out, lest it contain some private key material.
|
||||||
func scrubbedGoroutineDump() []byte {
|
func scrubbedGoroutineDump() []byte {
|
||||||
buf := make([]byte, 1<<20)
|
var buf []byte
|
||||||
buf = buf[:runtime.Stack(buf, true)]
|
// Grab stacks multiple times into increasingly larger buffer sizes
|
||||||
|
// to minimize the risk that we blow past our iOS memory limit.
|
||||||
|
for size := 1 << 10; size <= 1<<20; size += 1 << 10 {
|
||||||
|
buf = make([]byte, size)
|
||||||
|
buf = buf[:runtime.Stack(buf, true)]
|
||||||
|
if len(buf) < size {
|
||||||
|
// It fit.
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
return scrubHex(buf)
|
return scrubHex(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user