Uploaded image for project: 'Core ReactOS'
  1. Core ReactOS
  2. CORE-17554

Winsock Handles not inherited in CreateProcess called with bInheritHandles=TRUE

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Untriaged
    • Priority: Major
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: Networking
    • Labels:
      None

      Description

      This could be a problem in ntoskrnl, kernel32, or winsock. Trying to determine that now. (I believe I traced it down to winsock ws2helper DLL which cannot find context or catalog for handles inherited from parent, no idea how to fix.) (TRACED TO WINSOCK)

      When an existing process has several sockets created and active and creates a child process through the CreateProcess API function, the child process should be able to use the existing handles and find them in the correct connection state. This is not true under ReactOS 0.4.15-x86-dev (retesting now under latest, but I expect no difference). Under this build using an existing connected handle fails reporting winsock errors. This method is used by many open source network server applications, and was detected when porting SAMBA4 to ReactOS.

      I created a command line test application for it using Delphi, but it is a bit complicated to test because you need two processes and several connections.

      I apologize for the long test description, but here goes.

      To test you need to create two applications a command line client and a server paired to work in tandem doing a ping-pong set of tests. The server application is launched first and listens on a TCP port, creates a second socket sets it nonblocking and connects it to the first soring the 'accept' socket. It then sends a test message which it receives on the 'accept' socket and confirms it functions. The server then calls CreateProcess to execute the client with the handle inheritance parameter of CreateProcess set True.

      The client then gets the UINT handle number of the 'accept' socket for the active connection and then makes a blocking receive call recv() on it, expecting to receive the information sent by the server in its non-blocking call.

      Currently under ReactOS the client receives winsock errorĀ 10038 (not a socket) the moment it tries to use the inherited 'accept' socket.

      I haven't tested this with file handles to see if it's a problem for inheriting all handles, but socket handles are definitely not being inherited properly. Both parts of the test work correctly in Windows 10.

        Attachments

        1. CHLD_PROC.exe
          33 kB
        2. dhandle2.exe
          33 kB
        3. dhandle-noskip.exe
          38 kB
        4. DumpHandle2.zip
          4 kB
        5. DumpHandles.zip
          5 kB
        6. image-2021-05-07-20-33-21-036.png
          image-2021-05-07-20-33-21-036.png
          97 kB
        7. image-2021-05-07-21-33-10-285.png
          image-2021-05-07-21-33-10-285.png
          58 kB
        8. INHERITANCE_TEST_HANDLE_DUPES.txt
          5 kB
        9. PARNT_PROC.exe
          38 kB
        10. Socket inheritance failure details.txt
          3 kB
        11. UDP_DGRAM2.zip
          13 kB
        12. VirtualBox_REACTOS_4.15d_15_09_2021_11_46_02.png
          VirtualBox_REACTOS_4.15d_15_09_2021_11_46_02.png
          46 kB

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              bugdude bugdude
            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: