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

Crash with static build on Windows before entering main due to variable initialization order across compilation units

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • 5.15.1
    • 5.15.0
    • Core: Plugins
    • None
    • Qt 5.15.0 Commercial

      Windows 10, OS build 19041.450

      MSVC 2019 with CL version 19.26.28806 for x64

      QMAKE/jom under Qt Creator 4.12.1 (as supplied with the commercial installer).
    • Windows
    • b619f2a26ea2ab56e18a3f9a8b635f96fc479563

    Description

      I am seeing a repeatable crash before entering main with debug builds against a static build of Qt 5.15.

      Software versions:

      • Qt 5.15.0 Commercial
      • Windows 10, OS build 19041.450
      • MSVC 2019 with CL version 19.26.28806 for x64
      • QMAKE/jom under Qt Creator 4.12.1 (as supplied with the commercial installer).

      I am using the following configure line to build Qt:

       

      configure -commercial -debug-and-release -release -static -static-runtime -optimize-size  -schannel -qt-zlib -qt-libpng -qt-libjpeg -nomake examples -prefix C:\opt\Qt-5.15.0-static

      Here's my qmake.pro file:

       

      TEMPLATE = app
      QT += core
      CONFIG += c++14
      SOURCES = main.cpp
      TARGET = static_init_issue
      

       

      And here is my main:

       

      #include <QtPlugin>
      int main() {
          return 0;
      } 

       

      The crash occurs in QArrayData::deallocate after calling qRegisterStaticPluginFunction to initialize QWindowsVistaStylePlugin (under static initialization in Windows initterm function). 

      I note that the call to staticPluginList in qRegisterStaticPluginFunction returns a null pointer and that this function is called before anything in in the macro Q_GLOBAL_STATIC(StaticPluginList, staticPluginList) is called.  The issue appears to be related to order of static initialization across compilation units.

      Attachments

        1. static_init_issue.pro
          0.1 kB
        2. main.cpp
          0.1 kB

        Issue Links

          Activity

            People

              thiago Thiago Macieira
              psmith Paul Smith
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: