Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-54895

macOS: Creating QNetworkAccessManager with CoreFoundation event dispatcher deadlocks

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • None
    • 5.6.1, 5.7.0, 5.10.1
    • QPA
    • None
    • OS X 10.10, 10.11, 10.12
    • macOS

    Description

      When using QCoreApplication with CoreFoundation event dispatcher, attempting to create QNetworkAccessManager object seems to deadlock. Sample code:

      #include <QtCore/QCoreApplication>
      #include <QtNetwork/QNetworkAccessManager>
      
      #include <cstdlib>
      
      int main(int argc, char** argv)
      {
          ::setenv("QT_EVENT_DISPATCHER_CORE_FOUNDATION", "1", true);
          QCoreApplication a(argc, argv);
          QNetworkAccessManager nam;
          return 0;
      }
      

      Removing setenv call above, program terminates properly. Leaving it in makes program never quit; sampling the program produces the following callstacks:

      Call graph:
          942 Thread_41859195   DispatchQueue_1: com.apple.main-thread  (serial)
          + 942 start  (in libdyld.dylib) + 1  [0x7fff942ca5c9]
          +   942 main  (in a.out) + 84  [0x100a5be74]  a.cpp:10
          +     942 QNetworkAccessManager::QNetworkAccessManager(QObject*)  (in QtNetwork) + 40  [0x1010bab48]
          +       942 QNetworkAccessManagerPrivate::QNetworkAccessManagerPrivate()  (in QtNetwork) + 183  [0x1010bfef7]
          +         942 QNetworkConfigurationManager::QNetworkConfigurationManager(QObject*)  (in QtNetwork) + 36  [0x1010f0944]
          +           942 qNetworkConfigurationManagerPrivate()  (in QtNetwork) + 250  [0x1010f08fa]
          +             942 QNetworkConfigurationManagerPrivate::initialize()  (in QtNetwork) + 166  [0x1010f2066]
          +               942 QNetworkConfigurationManagerPrivate::updateConfigurations()  (in QtNetwork) + 2076  [0x1010f288c]
          +                 942 QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument)  (in QtCore) + 2196  [0x100c53a44]
          +                   942 QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const  (in QtCore) + 1717  [0x100c54675]
          +                     942 QSemaphore::acquire(int)  (in QtCore) + 79  [0x100a8a3ef]
          +                       942 QWaitCondition::wait(QMutex*, unsigned long)  (in QtCore) + 162  [0x100a90012]
          +                         942 QWaitConditionPrivate::wait(unsigned long)  (in QtCore) + 75  [0x100a9016b]
          +                           942 __psynch_cvwait  (in libsystem_kernel.dylib) + 10  [0x7fff92947136]
          942 Thread_41859197   DispatchQueue_2: com.apple.libdispatch-manager  (serial)
          + 942 _dispatch_mgr_thread  (in libdispatch.dylib) + 52  [0x7fff9085b26e]
          +   942 kevent64  (in libsystem_kernel.dylib) + 10  [0x7fff92948232]
          942 Thread_41859236: Qt bearer thread
            942 thread_start  (in libsystem_pthread.dylib) + 13  [0x7fff9775c3ed]
              942 _pthread_start  (in libsystem_pthread.dylib) + 176  [0x7fff9775efd7]
                942 _pthread_body  (in libsystem_pthread.dylib) + 131  [0x7fff9775f05a]
                  942 QThreadPrivate::start(void*)  (in QtCore) + 362  [0x100a8eb3a]
                    942 QThread::exec()  (in QtCore) + 110  [0x100a8b1ae]
                      942 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)  (in QtCore) + 401  [0x100c46eb1]
                        942 QEventDispatcherCoreFoundation::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)  (in QtCore) + 616  [0x100d097a8]
                          942 CFRunLoopRunSpecific  (in CoreFoundation) + 296  [0x7fff9b16abd8]
                            942 __CFRunLoopRun  (in CoreFoundation) + 1371  [0x7fff9b16b37b]
                              942 __CFRunLoopServiceMachPort  (in CoreFoundation) + 212  [0x7fff9b16beb4]
                                942 mach_msg  (in libsystem_kernel.dylib) + 55  [0x7fff9294164f]
                                  942 mach_msg_trap  (in libsystem_kernel.dylib) + 10  [0x7fff929424de]
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              sorvig Morten Sørvig
              mike.dld Mike Gelfand
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes