QString and Microsoft STL std::string crash // Visual Studio 2010 // 64 bit



  • Hi,

    I have an issue similar problem when running following program, i got a crash in the STL implementation of Microsoft. I filed a bug report there as well, as i do not know which one is responsible for the crash. The crash is reproduced when compiling and running following program:

    @
    #include <string>
    #include <QString>

    void foo(const QString& applicationName);
    const QString qApplicationName(“My Application”);
    std::string mApplicationName;

    int main( int argc, char* argv [])
    {
    foo(qApplicationName); return 0;
    }

    void foo(const QString& applicationName)
    {
    mApplicationName = applicationName.toStdString();
    }
    @

    compiled with
    /I”$(QTDIR)/include/QtCore” /Zi /nologo /W3 /WX- /Od /Oy- /D “AMD64” /D ”_WIN64” /D ”_AMD64” /D ”_DEBUG” /D “QT_NO_KEYWORDS” /D “NOMINMAX” /D “WIN32_LEAN_AND_MEAN” /D “VC_EXTRA_LEAN” /D “WIN32” /D ”_WINDOWS” /D ”_CRT_NONSTDC_NO_WARNINGS” /D ”_CRT_SECURE_NO_WARNINGS” /D ”_CRT_SECURE_NO_DEPRECATE” /D ”_CRT_NONSTDC_NO_DEPRECATE” /D ”_HAS_ITERATOR_DEBUGGING=0” /D ”_SECURE_SCL=0” /D ”_ATL_SECURE_NO_DEPRECATE” /D ”_CRT_NON_CONFORMING_SWPRINTFS” /D “STRSAFE_NO_DEPRECATE” /D “ACPL_USE_PROMOTED_HEADERS” /D “ACPL_USE_WINDOWS_COM_OBJECTS” /D ”_UNICODE” /D “UNICODE” /Gm- /EHsc /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /GR /openmp /Fa”obj_v100\x64\Debug\Application\STL_Crash_Windows\” /Fo”obj_v100\x64\Debug\Application\STL_Crash_Windows\” /Fd”obj_v100\x64\Debug\Application\STL_Crash_Windows\vc100.pdb” /FR”obj_v100\x64\Debug\Application\STL_Crash_Windows\” /Gd /wd”4290” /errorReport:queue

    linked with

    /OUT:”../bin\STL_Crash_Windows_x64_d.exe” /INCREMENTAL:NO /NOLOGO /LIBPATH:”$(QTDIR)/lib.x64” /LTCG:STATUS “QtCored4.lib” “Winmm.lib” /MANIFEST /ManifestFile:”obj_v100\x64\Debug\Application\STL_Crash_Windows\STL_Crash_Windows_x64_d.exe.intermediate.manifest” /ALLOWISOLATION /MANIFESTUAC:”level=’asInvoker’ uiAccess=’false’” /DEBUG /PDB:”STL_Crash_Windows_x64_d.pdb” /PGD:”STL_Crash_Windows_x64_d.pgd” /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /ERRORREPORT:QUEUE

    this is a really annoying one, and a show stopper for me right now.



  • Make sure you get your debug linkage right. If you link against STL in MDd, but use the Qt release libraries, you'll get crashes (I haven't deeply checked your compile/link flags). I haven't run into this type of crashes myself with proper usage, but I haven't used MSVC2010 either. Also there was a bug in one of the earlier versions of MSVC2010. You might want to check if you have an update available.



  • [quote author="Franzk" date="1289387550"]Make sure you get your debug linkage right. If you link against STL in MDd, but use the Qt release libraries, you'll get crashes (I haven't deeply checked your compile/link flags).[/quote]

    I have. Every single project has been compiled with /MDd and I am linking properly with the Qt debug libraries. There is no warning whatsoever by the linker that I would have ignored.

    [quote author="Franzk" date="1289387550"]I haven't run into this type of crashes myself with proper usage, but I haven't used MSVC2010 either. Also there was a bug in one of the earlier versions of MSVC2010. You might want to check if you have an update available.[/quote]

    I have seen this "thread":http://bugreports.qt.nokia.com/browse/QTBUG-11445 and am now recompiling Qt 4.7.1 (this is a bug fix release as well) after having applied the patch available "here":https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=31433

    I will let you know if this helps.



  • It helped. Applying this "patch":https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=31433 to the Visual Studio 2010 compiler and compiling Qt 4.7.1 with it helped.
    However, I still have a bad feeling about Microsoft'S implementation of the STL.


  • Moderators

    Qt does ship quite a bit of stuff that could be considered to be a duplication of functionality already in the STL... mostly since back in the days STL was not universally available in the first place. Looks like you found a platform where that still is the case today:-)



  • [quote author="Tobias Hunger" date="1289417842"]Qt does ship quite a bit of stuff that could be considered to be a duplication of functionality already in the STL... mostly since back in the days STL was not universally available in the first place. Looks like you found a platform where that still is the case today:-)[/quote]

    Would your advice be to compile Qt with -no-stl ?



  • You can try that. You could also try not using the STL conversion functions. I'd expect the latter to work without trouble and also without the need for you to rebuild Qt. It's probably not as clean, but hey, if it works...

    @std::string someString = (const char *)QString("huuhaa").toAscii();
    QString anotherString = someString.c_str();
    @



  • well i think the problem is not the MS-STL implementation (I guess lots of application would not work correctly then). I had the same bug with the VS2010 compiler. And the patch solved every release crash I had. I think the only problem was the bug in the compiler



  • [quote author="Felix" date="1289565002"]well i think the problem is not the MS-STL implementation (I guess lots of application would not work correctly then). I had the same bug with the VS2010 compiler. And the patch solved every release crash I had. I think the only problem was the bug in the compiler[/quote]

    The exact same patch that i am mentioning or another one ? Was that affecting only your x64 build or your Win32 build as well ?


Log in to reply
 

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