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

TWaitableNamedPipeImpl::read race condition can cause hang in ~TWaitableNamedPipeImpl

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.11.0
    • None
    • C++ - Library
    • None

    Description

      If the other side of the pipe disconnects in between a call to endAsyncRead and beginAsyncRead, then the beginAsyncRead will throw, but 
      ~TWaitableNamedPipeImpl will hang inside GetOverlappedResult. Here is some test code that reproduces the issue:

          std::promise<void> serverStarted, clientStarted, serverReadStarted, clientDestroyed;
          std::thread serverThread([&] {
              auto server = boost::make_shared<apache::thrift::transport::TPipeServer>("pipe-test", 64 * 1024, 1);
              server->listen();
              serverStarted.set_value();
              auto serverConnection = server->accept();
              clientStarted.get_future().wait();
              uint8_t buf[1024];
              serverConnection->read(buf, 1);
              serverReadStarted.set_value();
              clientDestroyed.get_future().wait();
              try {
                  serverConnection->read(buf, 1023);
              } catch (const apache::thrift::transport::TTransportException&) {
              }
          });
      
          serverStarted.get_future().wait();
      
          {
              auto client = boost::make_shared<apache::thrift::transport::TPipe>("pipe-test");
              client->open();
              uint8_t buf[1024]{};
              client->write(buf, 1024);
              clientStarted.set_value();
              serverReadStarted.get_future().wait();
          }
          clientDestroyed.set_value();
          serverThread.join();
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            jeremyspiegel Jeremy Spiegel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: