Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5186

AI_ADDRCONFIG: Thrift libraries crash with localhost-only network.

    XMLWordPrintableJSON

Details

    • Patch Available
    • Patch

    Description

      THRIFT-2539 has been reported, and fixed — but for win32 only, for no apparent reason. The exact same problem reproduces on POSIX.

      Namely, when no network interfaces besides lo (the 127.0.0.1 loopback interface) are up, C++ and Python apps linked with Thrift-generated code, both clients and servers — crash by throwing an exception. Even when the intention is exactly to run them on localhost only.

      This happens because Thrift library code for TSocket, TServerSocket, TNonblockingServerSocket calls getaddrinfo() to resolve target hostname to connect to/listen on, into concrete IP address (v4 or v6, whichever the system is configured for). To that call, it passes the AI_ADDRCONFIG hint which effectively turns a localhost-only situation into:

      Could not resolve host for client socket.

      and into this (server-side):

      гру 23 13:52:13 localhost.localdomain systemd[1]: db_cache.service: Main process exited, code=dumped, status=6/ABRT
      гру 23 13:52:13 localhost.localdomain systemd[1]: db_cache.service: Failed with result 'core-dump'.
      гру 23 13:52:17 localhost.localdomain db_cache[12912]: Thrift: Mon Dec 23 13:52:15 2019 TSocket::open() getaddrinfo() <Host: 127.0.0.1 Port: 1302>Address family for hostname not supported
      гру 23 13:52:17 localhost.localdomain db_cache[12912]: Thrift: Mon Dec 23 13:52:15 2019 TSocket::open() getaddrinfo() <Host: 127.0.0.1 Port: 8345>Address family for hostname not supported
      гру 23 13:52:17 localhost.localdomain db_cache[12912]: Thrift: Mon Dec 23 13:52:15 2019 TNonblocking: using dedicated listener thread, io threads: 16
      гру 23 13:52:17 localhost.localdomain db_cache[12912]: Thrift: Mon Dec 23 13:52:15 2019 getaddrinfo -9: Address family for hostname not supported
      гру 23 13:52:17 localhost.localdomain db_cache[12912]: terminate called after throwing an instance of 'apache::thrift::transport::TTransportException'
      гру 23 13:52:17 localhost.localdomain db_cache[12912]:   what():  Could not resolve host for server socket.
      

      I fail to understand the original reason to pass that AI_ADDRCONFIG hint. It shouldn't be there as I see it.

      Further, since Thrift 0.9.2, windows builds of thrift apps don't pass that hint anymore (see THRIFT-2539), and it seems to be okay.

      For comprehension, I'm attaching a sample patch to remove AI_ADDRCONFIG from lib/cpp and lib/py. The main change will be landing via GitHub, per Thrift's contribution process, so please follow there too.

      Attachments

        Activity

          People

            ulidtko Max
            ulidtko Max
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 6h 40m
                6h 40m