Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-28415

Utils::Id() c'tor is not thread safe

    XMLWordPrintable

Details

    • dc9cb0562a (qt-creator/qt-creator/9.0) dc9cb0562a (qt-creator/qt-creator/qds/dev) dc9cb0562a (qt-creator/qt-creator/master)

    Description

      The c'tor of Utils::Id() may potentially modify static cache (stringFromId and idFromString static QHash objects) and it's apparently called from various threads. E.g.:

      1  Utils::theId                                                                                                                                                                                                                                                                                                                                                                                                          id.cpp             86  0x7ffff7b05a87 
      2  Utils::Id::Id                                                                                                                                                                                                                                                                                                                                                                                                         id.cpp             123 0x7ffff7b05c8d 
      3  QmlJSEditor::Internal::QmlTaskManager::collectMessages                                                                                                                                                                                                                                                                                                                                                                qmltaskmanager.cpp 82  0x7fff7cd39bc7 
      4  Utils::Internal::runAsyncQFutureInterfaceDispatch<QmlJSEditor::Internal::QmlTaskManager::FileErrorMessages, void ( *)(QFutureInterface<QmlJSEditor::Internal::QmlTaskManager::FileErrorMessages>&, QmlJS::Snapshot, QList<QmlJS::ModelManagerInterface::ProjectInfo> const&, QmlJS::ViewerContext, bool), QmlJS::Snapshot, QList<QmlJS::ModelManagerInterface::ProjectInfo>, QmlJS::ViewerContext, bool>              runextensions.h    236 0x7fff7cd442a3 
      5  Utils::Internal::runAsyncMemberDispatch<QmlJSEditor::Internal::QmlTaskManager::FileErrorMessages, void ( *)(QFutureInterface<QmlJSEditor::Internal::QmlTaskManager::FileErrorMessages>&, QmlJS::Snapshot, QList<QmlJS::ModelManagerInterface::ProjectInfo> const&, QmlJS::ViewerContext, bool), QmlJS::Snapshot, QList<QmlJS::ModelManagerInterface::ProjectInfo>, QmlJS::ViewerContext, bool, void>                  runextensions.h    253 0x7fff7cd440f5 
      6  Utils::Internal::runAsyncImpl<QmlJSEditor::Internal::QmlTaskManager::FileErrorMessages, void ( *)(QFutureInterface<QmlJSEditor::Internal::QmlTaskManager::FileErrorMessages>&, QmlJS::Snapshot, QList<QmlJS::ModelManagerInterface::ProjectInfo> const&, QmlJS::ViewerContext, bool), QmlJS::Snapshot, QList<QmlJS::ModelManagerInterface::ProjectInfo>, QmlJS::ViewerContext, bool>                                  runextensions.h    282 0x7fff7cd43fb4 
      7  Utils::Internal::AsyncJob<QmlJSEditor::Internal::QmlTaskManager::FileErrorMessages, void ( *)(QFutureInterface<QmlJSEditor::Internal::QmlTaskManager::FileErrorMessages>&, QmlJS::Snapshot, QList<QmlJS::ModelManagerInterface::ProjectInfo> const&, QmlJS::ViewerContext, bool), QmlJS::Snapshot, QList<QmlJS::ModelManagerInterface::ProjectInfo>, QmlJS::ViewerContext, bool&>::runHelper<0ul, 1ul, 2ul, 3ul, 4ul> runextensions.h    351 0x7fff7cd43e00 
      8  Utils::Internal::AsyncJob<QmlJSEditor::Internal::QmlTaskManager::FileErrorMessages, void ( *)(QFutureInterface<QmlJSEditor::Internal::QmlTaskManager::FileErrorMessages>&, QmlJS::Snapshot, QList<QmlJS::ModelManagerInterface::ProjectInfo> const&, QmlJS::ViewerContext, bool), QmlJS::Snapshot, QList<QmlJS::ModelManagerInterface::ProjectInfo>, QmlJS::ViewerContext, bool&>::run                                runextensions.h    331 0x7fff7cd43c83 
      9  Utils::Internal::RunnableThread::run                                                                                                                                                                                                                                                                                                                                                                                  runextensions.cpp  17  0x7ffff7bf32a3 
      10 operator()                                                                                                                                                                                                                                                                                                                                                                                                            qthread_unix.cpp   355 0x7ffff55ba071 
      11 (anonymous namespace)::terminate_on_exception<QThreadPrivate::start(void *)::<lambda()>>(struct {...} &&)                                                                                                                                                                                                                                                                                                             qthread_unix.cpp   291 0x7ffff55bb193 
      12 QThreadPrivate::start                                                                                                                                                                                                                                                                                                                                                                                                 qthread_unix.cpp   314 0x7ffff55ba13d 
      13 start_thread                                                                                                                                                                                                                                                                                                                                                                                                          pthread_create.c   442 0x7ffff4dbeb43 
      14 clone3                                                                                                                                                                                                                                                                                                                                                                                                                clone3.S           81  0x7ffff4e50a00 
      

      This isn't thread safe and access to stringFromId and idFromString should be secured.

      Attachments

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

        Activity

          People

            jkobus Jarek Kobus
            jkobus Jarek Kobus
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes