-
Notifications
You must be signed in to change notification settings - Fork 781
OpenSSH for Windows hangs while writing to STDERR asynchronously #1427
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
Comments
Can you attempt this manually, if you still see the issue, can you provide your manual repro steps? |
manu0401
added a commit
to manu0401/openssh-portable
that referenced
this issue
Oct 31, 2024
stdio descriptors (stdin, stdout and stderr) can be operated in various modes by win32compat code. The behavior is set very early in fd_table_initialize() by setting pio->type. In PowerShell/Win32-OpenSSH#1427 it was chosen to set pio->type to NONSOCK_SYNC_FD to resolve an I/O hang problem. Unfortunately this introduce problems for other ssh usage. sshfs-wiun uses ssh and has at leas 6 open issues for the same problem introduced by this NONSOCK_SYNC_FD change: https://github.com/winfsp/sshfs-win/issues?q=is%3Aissue+cb+%3A87 The sshfs-win workaround it to use an older ssh.exe from cygwin, which is bundled with sshfs-win. This program is unable to use ssh-agent, which is quite frustrating. And if PATH is not set to use it, sshfs-win cannot work. This change introduce an OPENSSH_STDIO_MODE environment variable that can be set to the following values: unknown, sock, nonsock, nonsock_sync. It cause pio->type to be set to UNKNOWN_FD, SOCK_FD, NONSOCK_FD, and NONSOCK_SYNC_FD respecitively. The default behavior when the variable is not set is unchanged (which means NONSOCK_SYNC_FD). Setting OPENSSH_STDIO_MODE="nonsock" lets sshfs-win work again with openssh-portable ssh.exe. ssh-agent can be used, and this is good.
tgauth
pushed a commit
to PowerShell/openssh-portable
that referenced
this issue
Nov 19, 2024
* Add an environement variable to control stdio mode stdio descriptors (stdin, stdout and stderr) can be operated in various modes by win32compat code. The behavior is set very early in fd_table_initialize() by setting pio->type. In PowerShell/Win32-OpenSSH#1427 it was chosen to set pio->type to NONSOCK_SYNC_FD to resolve an I/O hang problem. Unfortunately this introduce problems for other ssh usage. sshfs-wiun uses ssh and has at leas 6 open issues for the same problem introduced by this NONSOCK_SYNC_FD change: https://github.com/winfsp/sshfs-win/issues?q=is%3Aissue+cb+%3A87 The sshfs-win workaround it to use an older ssh.exe from cygwin, which is bundled with sshfs-win. This program is unable to use ssh-agent, which is quite frustrating. And if PATH is not set to use it, sshfs-win cannot work. This change introduce an OPENSSH_STDIO_MODE environment variable that can be set to the following values: unknown, sock, nonsock, nonsock_sync. It cause pio->type to be set to UNKNOWN_FD, SOCK_FD, NONSOCK_FD, and NONSOCK_SYNC_FD respecitively. The default behavior when the variable is not set is unchanged (which means NONSOCK_SYNC_FD). Setting OPENSSH_STDIO_MODE="nonsock" lets sshfs-win work again with openssh-portable ssh.exe. ssh-agent can be used, and this is good. * Leave out UNKNOWN_FD as the possible rtpes for stdio descriptors An assert(pio->type != UNKNOWN_FD) in fd_table_set() causes that case to fail early anyway.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Troubleshooting steps
https://github.com/PowerShell/Win32-OpenSSH/wiki/Troubleshooting-Steps
Terminal issue? please go through wiki
https://github.com/PowerShell/Win32-OpenSSH/wiki/TTY-PTY-support-in-Windows-OpenSSH
Please answer the following
"OpenSSH for Windows" version
7.9p1, 8.0p1.
Server OperatingSystem
Debian rodete rodete (x86-64).
Client OperatingSystem
Windows 10, Windows Server 2016.
What is failing
Reproduced reliably with OpenSSH 7.9p1, 8.0p1:
I collected the call tack of
ssh.exe
on Windows:For some reason the asyn write
WriteFileEx
gets stuck writing to STDERR and the main thread hangs waiting for the write to be completed.I tried forcing the STDERR write to be sync and the problem goes away, i.e. in w32_write function, insert the following code:
Expected output
The SSH sessions complete without hanging.
Actual output
The Windows SSH session hangs while writing to STDERR asynchronously.
The text was updated successfully, but these errors were encountered: