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

Crash due to bug in QThreadStorageData

    XMLWordPrintable

Details

    • ccd3f663c8c96e266b173a6f825bccec830007e1

    Description

      This probably occurs because the first call to qrand() takes place from a static object destructor. qrand() attempts to allocate TLS for the seed, but the static QVector that QThreadStorageData uses to cache destructor functions has already been destroyed. This situation is not correctly handled by QThreadStorageData::QThreadStorageData() and the segfault occurs.

      Another issue is that QMap has implicit dependency on TLS (via qrand()) thus making it inherently unsafe to use as (or as part of) a static object.

      We are also generally concerned about the usage of static data in Qt as it seems that there is not always any explicit handling of the dependencies between various static objects. C++ only guarantees that the destructor of local static objects will be invoked in the reverse order of their construction and this leaves many potential scenarios where program termination will not be handled correctly. (We note that Q_GLOBAL_STATIC does at least create local static objects rather than nonlocal objects thus avoid undefined destruction order between compilation units.)

      The attached examples reproduces the problem.

      Attachments

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

        Activity

          People

            bhughes Bradley T. Hughes (closed Nokia Identity) (Inactive)
            stromme Christian
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes