Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

执行命令超时报错 #13

Open
wangsu728 opened this issue Dec 12, 2016 · 2 comments
Open

执行命令超时报错 #13

wangsu728 opened this issue Dec 12, 2016 · 2 comments
Assignees
Labels

Comments

@wangsu728
Copy link

在命令执行过程中,需要控制超时,同时对一些异常的情况作处理

# cloudcli exec -n golang -y -c 'yes'
fatal error: runtime: out of memory

runtime stack:
runtime.throw(0x85ad61, 0x16)
	/root/go/src/runtime/panic.go:566 +0x95
runtime.sysMap(0xc440300000, 0x20000000, 0xc42001e200, 0xa643f8)
	/root/go/src/runtime/mem_linux.go:219 +0x1d0
runtime.(*mheap).sysAlloc(0xa4b0c0, 0x20000000, 0xc42001cdc8)
	/root/go/src/runtime/malloc.go:407 +0x37a
runtime.(*mheap).grow(0xa4b0c0, 0x10000, 0x0)
	/root/go/src/runtime/mheap.go:726 +0x62
runtime.(*mheap).allocSpanLocked(0xa4b0c0, 0x10000, 0x43e908)
	/root/go/src/runtime/mheap.go:630 +0x4f2
runtime.(*mheap).alloc_m(0xa4b0c0, 0x10000, 0x7f0100000000, 0x7fb722bfcd70)
	/root/go/src/runtime/mheap.go:515 +0xe0
runtime.(*mheap).alloc.func1()
	/root/go/src/runtime/mheap.go:579 +0x4b
runtime.systemstack(0x7fb722bfcd78)
	/root/go/src/runtime/asm_amd64.s:314 +0xab
runtime.(*mheap).alloc(0xa4b0c0, 0x10000, 0x10100000000, 0xc4200eb500)
	/root/go/src/runtime/mheap.go:580 +0x73
runtime.largeAlloc(0x1ffffe00, 0xc4200eb401, 0xc42016fd80)
	/root/go/src/runtime/malloc.go:774 +0x93
runtime.mallocgc.func1()
	/root/go/src/runtime/malloc.go:669 +0x3e
runtime.systemstack(0xc42001d500)
	/root/go/src/runtime/asm_amd64.s:298 +0x79
runtime.mstart()
	/root/go/src/runtime/proc.go:1079

goroutine 36 [running]:
runtime.systemstack_switch()
	/root/go/src/runtime/asm_amd64.s:252 fp=0xc42016fc88 sp=0xc42016fc80
runtime.mallocgc(0x1ffffe00, 0x7c3ac0, 0xc42016fd01, 0x45ee60)
	/root/go/src/runtime/malloc.go:670 +0x903 fp=0xc42016fd28 sp=0xc42016fc88
runtime.makeslice(0x7c3ac0, 0x1ffffe00, 0x1ffffe00, 0xe00, 0x0, 0x0)
	/root/go/src/runtime/slice.go:57 +0x7b fp=0xc42016fd80 sp=0xc42016fd28
bytes.makeSlice(0x1ffffe00, 0x0, 0x0, 0x0)
	/root/go/src/bytes/buffer.go:198 +0x77 fp=0xc42016fdc0 sp=0xc42016fd80
bytes.(*Buffer).ReadFrom(0xc4201129a0, 0x7fb728ab53b0, 0xc42008e300, 0xc420165e98, 0xa62301, 0x1)
	/root/go/src/bytes/buffer.go:170 +0x2a9 fp=0xc42016fe30 sp=0xc42016fdc0
io.copyBuffer(0xa18aa0, 0xc4201129a0, 0x7fb728ab53b0, 0xc42008e300, 0x0, 0x0, 0x0, 0x841c40, 0x0, 0x7fb728ab53b0)
	/root/go/src/io/io.go:384 +0x323 fp=0xc42016feb8 sp=0xc42016fe30
io.Copy(0xa18aa0, 0xc4201129a0, 0x7fb728ab53b0, 0xc42008e300, 0xc42008e300, 0x0, 0x0)
	/root/go/src/io/io.go:360 +0x68 fp=0xc42016ff18 sp=0xc42016feb8
golang.org/x/crypto/ssh.(*Session).stdout.func1(0x0, 0x0)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/session.go:476 +0x7b fp=0xc42016ff68 sp=0xc42016ff18
golang.org/x/crypto/ssh.(*Session).start.func1(0xc4200946c0, 0xc4200f9a50)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/session.go:361 +0x27 fp=0xc42016ffa0 sp=0xc42016ff68
runtime.goexit()
	/root/go/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc42016ffa8 sp=0xc42016ffa0
created by golang.org/x/crypto/ssh.(*Session).start
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/session.go:362 +0x132

goroutine 1 [chan receive]:
main.concurrentExecCmd(0xc420114000, 0x1, 0x1, 0xc4200f89e0, 0x1, 0xc4200f8970, 0x1, 0x1, 0xc4200f89e4, 0x4, ...)
	/root/cloud-cli/src/cmd/cloudcli/exec.go:166 +0x63a
main.execCmd(0xc4200f89e0, 0x1, 0xc4200f8970, 0x1, 0x1, 0xc4200f89e4, 0x4, 0xc4200f89e8, 0x3, 0x1, ...)
	/root/cloud-cli/src/cmd/cloudcli/exec.go:120 +0x16e
main.initExecSubCmd.func1(0xc420018b40, 0x0, 0x0)
	/root/cloud-cli/src/cmd/cloudcli/exec.go:75 +0x24a
reflect.Value.call(0x7d1720, 0x888f98, 0x13, 0x8539b9, 0x4, 0xc42004b8e0, 0x1, 0x1, 0x485918, 0x8466a0, ...)
	/root/go/src/reflect/value.go:434 +0x5c8
reflect.Value.Call(0x7d1720, 0x888f98, 0x13, 0xc42004b8e0, 0x1, 0x1, 0xc4200f89a1, 0x140, 0x140)
	/root/go/src/reflect/value.go:302 +0xa4
github.com/urfave/cli.HandleAction(0x7d1720, 0x888f98, 0xc420018b40, 0x0, 0x0)
	/root/cloud-cli/vendor/src/github.com/urfave/cli/app.go:480 +0x1e0
github.com/urfave/cli.Command.Run(0x853b99, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x857316, 0xe, 0x0, ...)
	/root/cloud-cli/vendor/src/github.com/urfave/cli/command.go:186 +0xc26
github.com/urfave/cli.(*App).Run(0xc4200e6000, 0xc42000c070, 0x7, 0x7, 0x0, 0x0)
	/root/cloud-cli/vendor/src/github.com/urfave/cli/app.go:236 +0x60c
main.main()
	/root/cloud-cli/src/cmd/cloudcli/main.go:54 +0x10a

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
	/root/go/src/runtime/asm_amd64.s:2086 +0x1

goroutine 4 [syscall]:
os/signal.signal_recv(0x0)
	/root/go/src/runtime/sigqueue.go:116 +0x157
os/signal.loop()
	/root/go/src/os/signal/signal_unix.go:22 +0x22
created by os/signal.init.1
	/root/go/src/os/signal/signal_unix.go:28 +0x41

goroutine 5 [select]:
runner/sshrunner.(*SSHClient).ExecNointeractiveCmd(0xc4201141e0, 0xc4200faf40, 0x14, 0x6fc23ac00, 0x853b9d, 0x4, 0xc4201129a0, 0xc420112a10, 0x0, 0x0)
	/root/cloud-cli/src/runner/sshrunner/ssh_client.go:78 +0x5cc
runner/sshrunner.(*SSHRunner).SyncExec(0xc4200f8fe0, 0xc4200f89e4, 0x4, 0xc4200d5d60, 0x14, 0xc4200f89e8, 0x3, 0x6fc23ac00, 0x0)
	/root/cloud-cli/src/runner/sshrunner/sshrunner.go:41 +0x12c
runner/sshrunner.(*SSHRunner).ConcurrentExec(0xc4200f8fe0, 0xc4200f89e4, 0x4, 0xc4200d5d60, 0x14, 0xc4200f89e8, 0x3, 0x6fc23ac00, 0xc420114180, 0xc420094480)
	/root/cloud-cli/src/runner/sshrunner/sshrunner.go:55 +0x9d
created by main.concurrentExecCmd
	/root/cloud-cli/src/cmd/cloudcli/exec.go:162 +0x4a4

goroutine 19 [running]:
	goroutine running on other thread; stack unavailable
created by golang.org/x/crypto/ssh.newClientTransport
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/handshake.go:97 +0x2a6

goroutine 11 [runnable]:
golang.org/x/crypto/ssh.(*handshakeTransport).readPacket(0xc420148000, 0xc426bf0000, 0x4009, 0x4009, 0x0, 0x0)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/handshake.go:120 +0x64
golang.org/x/crypto/ssh.(*mux).onePacket(0xc420113030, 0x0, 0x0)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/mux.go:215 +0x37
golang.org/x/crypto/ssh.(*mux).loop(0xc420113030)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/mux.go:190 +0x43
created by golang.org/x/crypto/ssh.newMux
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/mux.go:128 +0x1df

goroutine 12 [chan receive]:
golang.org/x/crypto/ssh.(*Client).handleGlobalRequests(0xc420055b40, 0xc4201149c0)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/client.go:132 +0x4e
created by golang.org/x/crypto/ssh.NewClient
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/client.go:55 +0xee

goroutine 13 [chan receive]:
golang.org/x/crypto/ssh.(*Client).handleChannelOpens(0xc420055b40, 0xc420114900)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/client.go:141 +0x73
created by golang.org/x/crypto/ssh.NewClient
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/client.go:56 +0x11a

goroutine 14 [semacquire]:
sync.runtime_notifyListWait(0xc420055b10, 0x0)
	/root/go/src/runtime/sema.go:267 +0x122
sync.(*Cond).Wait(0xc420055b00)
	/root/go/src/sync/cond.go:57 +0x80
golang.org/x/crypto/ssh.(*mux).Wait(0xc420113030, 0x0, 0x0)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/mux.go:110 +0x9c
golang.org/x/crypto/ssh.NewClient.func1(0xc420055b40)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/client.go:58 +0x33
created by golang.org/x/crypto/ssh.NewClient
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/client.go:60 +0x13c

goroutine 15 [chan receive]:
golang.org/x/crypto/ssh.(*forwardList).handleChannels(0xc420055b50, 0xc420114a20)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/tcpip.go:178 +0x71
created by golang.org/x/crypto/ssh.NewClient
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/client.go:61 +0x18f

goroutine 16 [chan receive]:
golang.org/x/crypto/ssh.(*Session).wait(0xc4200946c0, 0xc420114a80, 0x8895d0, 0x0)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/session.go:400 +0x90
golang.org/x/crypto/ssh.newSession.func1(0xc4200946c0, 0xc420114a80)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/session.go:558 +0x35
created by golang.org/x/crypto/ssh.newSession
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/session.go:559 +0xde

goroutine 34 [chan receive]:
golang.org/x/crypto/ssh.(*Session).Wait(0xc4200946c0, 0xc4200faf40, 0x14)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/session.go:380 +0x6d
runner/sshrunner.(*SSHClient).ExecNointeractiveCmd.func1(0xc4200f9010, 0xc4200faf40, 0x14, 0xc420114240, 0xc4200946c0)
	/root/cloud-cli/src/runner/sshrunner/ssh_client.go:72 +0x8b
created by runner/sshrunner.(*SSHClient).ExecNointeractiveCmd
	/root/cloud-cli/src/runner/sshrunner/ssh_client.go:76 +0x2ff

goroutine 37 [semacquire]:
sync.runtime_notifyListWait(0xc420055c10, 0x0)
	/root/go/src/runtime/sema.go:267 +0x122
sync.(*Cond).Wait(0xc420055c00)
	/root/go/src/sync/cond.go:57 +0x80
golang.org/x/crypto/ssh.(*buffer).Read(0xc42015da00, 0xc4200dd800, 0x200, 0x200, 0x0, 0x0, 0x0)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/buffer.go:95 +0x138
golang.org/x/crypto/ssh.(*channel).ReadExtended(0xc42008e300, 0xc4200dd800, 0x200, 0x200, 0x1, 0xc4200dd800, 0x200, 0x200)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/channel.go:347 +0x165
golang.org/x/crypto/ssh.(*extChannel).Read(0xc4200f9a80, 0xc4200dd800, 0x200, 0x200, 0x782d01, 0x7fb728ab5388, 0xc420166630)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/channel.go:486 +0x53
bytes.(*Buffer).ReadFrom(0xc420112a10, 0x7fb728ab5338, 0xc4200f9a80, 0xc420166698, 0xa62301, 0x1)
	/root/go/src/bytes/buffer.go:176 +0x155
io.copyBuffer(0xa18aa0, 0xc420112a10, 0x7fb728ab5338, 0xc4200f9a80, 0x0, 0x0, 0x0, 0x7e6da0, 0xc4200f9a00, 0x7fb728ab5338)
	/root/go/src/io/io.go:384 +0x323
io.Copy(0xa18aa0, 0xc420112a10, 0x7fb728ab5338, 0xc4200f9a80, 0xc4200f9a80, 0x0, 0x0)
	/root/go/src/io/io.go:360 +0x68
golang.org/x/crypto/ssh.(*Session).stderr.func1(0x0, 0x0)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/session.go:489 +0x8f
golang.org/x/crypto/ssh.(*Session).start.func1(0xc4200946c0, 0xc4200f9a70)
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/session.go:361 +0x27
created by golang.org/x/crypto/ssh.(*Session).start
	/root/cloud-cli/vendor/src/golang.org/x/crypto/ssh/session.go:362 +0x132
@linuxr linuxr self-assigned this Dec 24, 2016
@linuxr linuxr added bug and removed bug labels Dec 24, 2016
@linuxr
Copy link
Contributor

linuxr commented Dec 27, 2016

超时时间配置文件中可以设置。
重现的方式可否提供下

@linuxr
Copy link
Contributor

linuxr commented Dec 27, 2016

我尝试了下,估计是 yes 这个命令返回的内容太多。超时时间设置过长的话,返回的内容太多,导致内存溢出。
现在开源版中未对返回值进行截断

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants