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

Recursion in qDetectCpuFeatures() causes freeze

    XMLWordPrintable

    Details

    • Platform/s:
      All
    • Commits:
      15edba41014690332f4753f932fa7d928096cb73 (qt/qtbase/5.12)

      Description

      Found when investigating QTBUG-77113, where the application freezes on startup on a x86_64 emulator for Android.

      It looks like

      1. qDetectCpuFeatures() calls qFatal(),
      2. This which will initialize a default logging category and register it to a hash in a global registry.
      3. QHash will salt the hash with a random number.
      4. This number is generated by the QRandomGenerator, which will call qDetectCpuFeatures().
      5. On the second call, it will hang on the guard for the global static QLoggingCategory

      Here is a full stack trace of the recursion and freeze:

      1   syscall                                                                                                                        0x7fee5dc68b98 
      2   __futex_wait_ex(void volatile *, bool, int, bool, timespec const *)                                                            0x7fee5dc6bcd6 
      3   pthread_cond_wait                                                                                                              0x7fee5dcd419e 
      4   std::__ndk1::__libcpp_condvar_wait                                                                     __threading_support 287 0x7fedc6881e95 
      5   __cxa_guard_acquire                                                                                    cxa_guard.cpp       213 0x7fedc6881e95 
      6   QLoggingCategory::defaultCategory()                                                                                            0x7fedc632ec25 
      7   qt_message_print(QtMsgType, QMessageLogContext const&, QString const&)                                                         0x7fedc61e6fbf 
      8   qt_message(QtMsgType, QMessageLogContext const&, const char *, __va_list_tag *)                                                0x7fedc61e3077 
      9   QMessageLogger::fatal(const char *, ...) const                                                                                 0x7fedc61e4b03 
      10  qDetectCpuFeatures()                                                                                                           0x7fedc6267e3a 
      11  QRandomGenerator::SystemGenerator::generate(unsigned int *, unsigned int *)                                                    0x7fedc61e8329 
      12  qt_create_qhash_seed()                                                                                                         0x7fedc6240339 
      13  QHashData::detach_helper(void ( *)(QHashData::Node *, void *), void ( *)(QHashData::Node *), int, int)                         0x7fedc6240528 
      14  QHash<QLoggingCategory *, QtMsgType>::insert(QLoggingCategory * const&, QtMsgType const&)                                      0x7fedc6332481 
      15  QLoggingRegistry::registerCategory(QLoggingCategory *, QtMsgType)                                                              0x7fedc63316eb 
      16  QLoggingCategory::defaultCategory()                                                                                            0x7fedc632ec67 
      17  qt_message_print(QtMsgType, QMessageLogContext const&, QString const&)                                                         0x7fedc61e6fbf 
      18  qt_message(QtMsgType, QMessageLogContext const&, const char *, __va_list_tag *)                                                0x7fedc61e3077 
      19  QMessageLogger::fatal(const char *, ...) const                                                                                 0x7fedc61e4b03 
      20  qDetectCpuFeatures()                                                                                                           0x7fedc6267e3a 
      ... <More>                                                                                                                                        
      

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              thiago Thiago Macieira
              Reporter:
              esabraha Eskil Abrahamsen Blomfeldt
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes