ssh (client) stucks in an endless loop with 100% CPU
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
openssh (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
I have automation suite, which uses ssh to connect to servers.
Under high speed conditions (I was never able to reproduce this manually, but many times in the script), ssh can stuck in an endless loop, causing 100% CPU usage.
strace on it looks like this:
ioctl(5, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(5, SNDCTL_TMR_CONTINUE or TCSETSF, {B38400 opost isig icanon echo ...}) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGTTOU {si_signo=SIGTTOU, si_code=SI_KERNEL} ---
rt_sigreturn(
ioctl(5, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(5, SNDCTL_TMR_CONTINUE or TCSETSF, {B38400 opost isig icanon echo ...}) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
(repeated endlessly)
Command line during call:
timeout 120 ssh -o StrictHostKeyCh
(IP address and a private key are changed on every run).
This ssh script is called from a shell script, which is in turn called by python supbrocess.
backtrace:
#0 0x00007fe7ad8f4ed8 in tcsetattr () from /lib/x86_
#1 0x000055cbfd2544d6 in ?? ()
#2 0x000055cbfd22cf57 in ?? ()
#3 0x000055cbfd2064b0 in ?? ()
#4 0x000055cbfd208bdd in ?? ()
#5 0x000055cbfd208d28 in ?? ()
#6 0x000055cbfd230c59 in ?? ()
#7 0x000055cbfd2088a4 in ?? ()
#8 0x000055cbfd204b44 in ?? ()
#9 0x000055cbfd1f3f26 in ?? ()
#10 0x00007fe7ad8183f1 in __libc_start_main () from /lib/x86_
#11 0x000055cbfd1f5b0a in ?? ()
Package versions:
ii libc6:amd64 2.24-3ubuntu1 amd64 GNU C Library: Shared libraries
ii openssh-client 1:7.3p1-3build1 amd64 secure shell (SSH) client, for secure access to remote machines
uname:
Linux 4.8.0-26-generic #28-Ubuntu SMP Tue Oct 18 14:39:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
ProblemType: Bug
DistroRelease: Ubuntu 17.04
Package: ssh (not installed)
ProcVersionSign
Uname: Linux 4.8.0-26-generic x86_64
ApportVersion: 2.20.3-0ubuntu8
Architecture: amd64
CurrentDesktop: X-Cinnamon
Date: Fri Dec 2 13:29:50 2016
EcryptfsInUse: Yes
InstallationDate: Installed on 2013-07-19 (1231 days ago)
InstallationMedia: Xubuntu 13.04 "Raring Ringtail" - Release i386 (20130423.1)
SourcePackage: openssh
UpgradeStatus: Upgraded to zesty on 2016-11-22 (9 days ago)
I was able to debug issue. It happens when 'timeout 120 ssh' is run without --foreground option for timeout and remote server is asking for password. timeout without --foreground, when run from the script will block all input from stdin, which cause ssh to hangs in the loop.