[solved] Qt 5.2 build (VS 2013 64-bit) generates crashing EXEs



  • Hi,

    I followed these steps to create a 64-bit build of Qt 5.2 using Visual Studio 2013 (everything done from the Visual Studio 2013 x64 Command Prompt):

    • I cloned the git repository: git clone git://gitorious.org/qt/qt5.git <qt-install-dir>

    • I ran the init-repository script: perl ./init-repository --no-webkit

    • I configured the build environment as follows:

    configure -debug-and-release -mp -opensource -platform win32-msvc2013 -nomake examples -nomake tests -developer-build

    • I started the build process: nmake

    The following environment variables are set:
    PATH=..;<qt-install-dir>\qtbase\bin
    QTDIR=<qt-install-dir>\qtbase
    QT_QPA_PLATFORM_PLUGIN_PATH=<qt-install-dir>\qtbase\plugins\platforms

    The build compiles without errors, and I am able to build and run my own C++ application using this Qt build. However, some of the EXEs in the qtbase\bin folder do not work, e.g. assistant.exe, designer.exe or linguist.exe. For instance, if I try to run designer.exe, I get an immediate crash in memcpy() within a call to msvcr120.dll, which is the Microsoft Visual C++ 12 Runtime Library shipped with Visual Studio 2013.

    I know that changes have been introduced in memory alignment between VS 2010 and VS 2012 (and possibly also from VS2012 to VS2013) which can lead to this sort of crashes when builds of different VS platform toolsets are linked together. However, I built Qt using a single platform toolset (win32-msvc2013). Does anyone know how to solve this problem? I should add that everything works fine if I build Qt using VS2010 (which employs a different version of the MSVC Runtime), so this might be caused by some sort of incompatibility between Qt and the MSVC 12 Runtime.

    Best regards,
    Andi


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Since it's concerning VS 2013 which is pretty new, I think you should bring this question to the interest mailing list, you'll find there Qt's developers/maintainers (this forum is more user oriented)



  • Hi SGaist,

    thanks for you reply. I asked again on the interest mailing list.

    I recently did a recompile with VS 2010 and I get the same crash, this time with msvcrt10.dll (memcpy() call by Qt5Core.dll). Thus, I assume this must have something to do with an error in the current qt5 git repository.



  • Some more details:

    Stack Trace:
    msvcr120d.dll!memcpy() Zeile 128 Asm
    Qt5Cored.dll!_q_toHex<char,unsigned char>'::2'::digits() + 0xba5 Bytes C++
    00000000002dea3d()
    Qt5Cored.dll!QByteArray::QByteArray(const char * data, int size) Zeile 1386 C++

    Qt5Cored.dll!QLibraryPrivate::fromRawMetaData(const char * raw) Zeile 115 + 0x22 Bytes C++
    Qt5Cored.dll!findPatternUnloaded(const QString & library, QLibraryPrivate * lib) Zeile 307 + 0x12 Bytes C++
    Qt5Cored.dll!QLibraryPrivate::updatePluginState() Zeile 689 + 0x1c Bytes C++
    Qt5Cored.dll!QLibraryPrivate::isPlugin() Zeile 662 C++
    Qt5Cored.dll!QFactoryLoader::update() Zeile 161 + 0xa Bytes C++
    Qt5Cored.dll!QFactoryLoader::QFactoryLoader(const char * iid, const QString & suffix, Qt::CaseSensitivity cs) Zeile 105 C++
    Qt5Guid.dll!anonymous namespace'::Q_QGS_directLoader::innerFunction() Zeile 57 + 0xb9 Bytes C++ Qt5Guid.dll!QGlobalStatic<QFactoryLoader,&anonymous namespace'::Q_QGS_directLoader::innerFunction,A0x09d6b84c::Q_QGS_directLoader::guard>::operator()() Zeile 128 + 0x23 Bytes C++
    Qt5Guid.dll!QPlatformIntegrationFactory::create(const QString & platform, const QStringList & paramList, int & argc, char * * argv, const QString & platformPluginPath) Zeile 78 + 0xc Bytes C++
    Qt5Guid.dll!init_platform(const QString & pluginArgument, const QString & platformPluginPath, int & argc, char * * argv) Zeile 897 + 0x2c Bytes C++
    Qt5Guid.dll!QGuiApplicationPrivate::createPlatformIntegration() Zeile 1028 + 0x5e Bytes C++
    Qt5Guid.dll!QGuiApplicationPrivate::createEventDispatcher() Zeile 1046 C++
    Qt5Widgetsd.dll!QApplicationPrivate::createEventDispatcher() Zeile 86 C++
    Qt5Cored.dll!QCoreApplication::init() Zeile 709 C++
    Qt5Cored.dll!QCoreApplication::QCoreApplication(QCoreApplicationPrivate & p) Zeile 635 + 0xa Bytes C++
    Qt5Guid.dll!QGuiApplication::QGuiApplication(QGuiApplicationPrivate & p) Zeile 493 + 0x1e Bytes C++
    Qt5Widgetsd.dll!QApplication::QApplication(int & argc, char * * argv, int _internal) Zeile 538 + 0x68 Bytes C++
    TestApplication.exe!main(int argc, char * * argv) Zeile 20 +

    The error seems to be related to locating the platform plugin:

    static inline QJsonDocument fromRawMetaData(const char *raw) {
        raw += strlen("QTMETADATA  ");
        // the size of the embedded JSON object can be found 8 bytes into the data (see qjson_p.h),
        // but doesn't include the size of the header (8 bytes)
        QByteArray json(raw, qFromLittleEndian<uint>(*(uint *)(raw + 8)) + 8); // crashes here
        return QJsonDocument::fromBinaryData(json);
    }
    


  • Found the error. If QT_QPA_PLATFORM_PLUGIN_PATH is set as environment variable, QT crashes at finding the platform plugin. I still don't understand why, especially since the variable was set to the correct path (qtbase\plugins\platforms) and even if not, Qt should report an error instead of crashing. Weird..


  • Lifetime Qt Champion

    Great you found out ! And thanks for sharing

    Can you also update the thread title preceding [solved] ? So other forum users may know a solution has been found :)



  • Some more background info:

    If I deploy a Qt application without Qt being present at the built-in search paths (see qtbase\src\corelib\global\qconfig.cpp), the platform plugin is not found even if there is a subdir "platforms" with the according DLLs. However, this can be fixed by adding the current path to the library search path before instantiating a window: QApplication::addLibraryPath(".").

    [Note: If libEGL.dll is not present, the "missing platform plugin" error is displayed even if everything else is set up right. This is a different issue.]

    Alternatively (!), one may pass "-platformpluginpath <path>" to the EXE, or set the environment variable QT_QPA_PLATFORM_PLUGIN_PATH=<path>. However, Qt crashes if both happens at the same time, i.e. if the current path is in the library search path and a different platform plugin path is defined by either the environment variable or the "-platformpluginpath" command-line parameter.

    Appearently there are two Qt bugs involved:

    1. If a separate platform plugin path is defined externally (environment variable or "-platformpluginpath" parameter), there seem to be some conditions leading to a crash while trying to locate the platform plugins.

    2. For some reason, the code locating the platform plugin is not (at least, not always) looking at the current working directory. Thus, platform plugins located at "<currentDir>/platforms" are not found, except if "." is programmatically added to the library paths.

    Interestingly, the other plugins seem to be located in a different way. E.g., if I put a folder called "imageformats" below the working directory, all imageformat plugins are loaded correctly without the need of programmatically adding library search paths.


  • Lifetime Qt Champion

    Since you found a way to reproduce this relatively easily, you should present the problem to the interest mailing list, you'll find there Qt's developers/maintainers (this forum is more user oriented)

    You can also check the "bug report system":http://bugreports.qt-project.org to see if it's something known maybe open a new bug report with the methodology to reproduce the problem


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.