[Bug 3022] New: "dup() in/out/err failed" is output when stdin, stdout, or stderr is a TCP/IP socket

bugzilla-daemon at bugzilla.mindrot.org bugzilla-daemon at bugzilla.mindrot.org
Wed Jun 26 02:08:58 AEST 2019


https://bugzilla.mindrot.org/show_bug.cgi?id=3022

            Bug ID: 3022
           Summary: "dup() in/out/err failed" is output when stdin,
                    stdout, or stderr is a TCP/IP socket
           Product: Portable OpenSSH
           Version: 8.0p1
          Hardware: ix86
                OS: Windows 10
            Status: NEW
          Severity: normal
          Priority: P5
         Component: ssh
          Assignee: unassigned-bugs at mindrot.org
          Reporter: minidino at mailinator.com

Due to limitations in Windows, the CreateProcess() API accepts
anonymous pipes for the stdin, stdout, and stderr handles.  However,
buried in the MSDN docs is information that states that anonymous pipes
cannot be made non-blocking.  This creates a situation where two
processes can deadlock (e.g. one process is blocking on stdin while
another process is blocking on stdout or stderr).

There are two known fixes for this on Windows:  Use multiple threads
(one thread for each pipe) or use a little-known mode of
CreateProcess() and pass connected TCP/IP socket handles for each of
the pipes to the target process instead of anonymous pipes.  Not all
languages support multithreading and using a thread per pipe is kind of
wasteful of system resources.  Of course, establishing a TCP/IP
connection per pipe is also wasteful but enables single-threaded,
non-blocking code to work without deadlocking both processes.  Most
processes work fine with TCP/IP stdout/stderr (TCP/IP stdin is a bit
more iffy and depends on how the underlying C library works).

OpenSSH calls dup() in ssh.c and then bails out with the error message
"dup() in/out/err failed" when it can't duplicate socket handle(s). 
The connection then terminates.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list