Results 1 to 2 of 2

Thread: QMap destructor got CRT detected message

  1. #1
    Join Date
    Feb 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QMap destructor got CRT detected message

    Iam getting CRT Heap corruption detected message, when running the following simple c++ code. The error comes from ::free method called by QMap destrcutor.

    Qt Code:
    1. void foo() {
    2. QMap<QString, QVariant> map;
    3. map["Sample1"] = 2;
    4. map["Sample2"] = 3;
    5. }
    To copy to clipboard, switch view to plain text mode 
    I am using Qt 5.5.1 (It built Qt with Visual Studio 2013 and configure it to target windows xp(using v120_xp toolset)).

    Preconditions:

    My operating system is Windows 8 64 bit.
    I changed the Platform Tools property to Visual Studio 2013 - Windows XP (v120_xp).
    When I change the code to following, the error is gone.

    Qt Code:
    1. void foo() {
    2. QMap<QString, int> map; // Change the second type from QVariant to int
    3. map["Sample1"] = 2;
    4. map["Sample2"] = 3;
    5. }
    To copy to clipboard, switch view to plain text mode 
    Any help will be appreciated.


    Stacktrace contains following lines:
    Qt Code:
    1. msvcr120d.dll!_free_dbg_nolock(void * pUserData, int nBlockUse) Line 1376 C++
    2. msvcr120d.dll!_free_dbg(void * pUserData, int nBlockUse) Line 1265 C++
    3. msvcr120d.dll!free(void * pUserData) Line 49 C++
    4. Qt5Cored.dll!qMapDeallocate(QMapNodeBase * node, int alignment) Line 318 C++
    5. Qt5Cored.dll!QMapDataBase::freeTree(QMapNodeBase * root, int alignment) Line 349 C++
    6. Qt5Cored.dll!QMapDataBase::freeTree(QMapNodeBase * root, int alignment) Line 349 C++
    7. Armaghan.exe!QMapData<QString,QVariant>::destroy() Line 225 C++
    8. Armaghan.exe!QMap<QString,QVariant>::~QMap<QString,QVariant>() Line 339 C++
    9. Armaghan.exe!foo() Line 32 C++
    10. Armaghan.exe!main(int argc, char * * argv) Line 37 C++
    11. [External Code]
    To copy to clipboard, switch view to plain text mode 
    Last edited by hosseinzolfi; 7th February 2017 at 09:14.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QMap destructor got CRT detected message

    I have just tested it with Qt5.4.2 MinGWx32 and with Qt5.6.2 Visual Studio 2015, both run without any problem.
    Can you post the full project?
    Maybe you are doing something not visible in the code you posted.

    Does this run for you:
    Qt Code:
    1. #include <QCoreApplication>
    2. #include <QMap>
    3. #include <QString>
    4. #include <QVariant>
    5.  
    6. void foo() {
    7. QMap<QString, QVariant> map;
    8. map["Sample1"] = 2;
    9. map["Sample2"] = 3;
    10. }
    11.  
    12. int main(int argc, char *argv[])
    13. {
    14. QCoreApplication a(argc, argv);
    15. foo();
    16. return a.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. No version of QT detected
    By psykomusic in forum Newbie
    Replies: 7
    Last Post: 12th April 2016, 17:03
  2. QMap value type with virtual destructor
    By Vikram.Saralaya in forum Qt Programming
    Replies: 3
    Last Post: 25th November 2015, 11:23
  3. No mouseButtonRelease detected
    By maitrezeta in forum Qt Programming
    Replies: 4
    Last Post: 3rd September 2010, 16:23
  4. glibc detected
    By raghvendramisra in forum Qt Programming
    Replies: 5
    Last Post: 28th May 2008, 04:29
  5. QMap destructor bug
    By Ruud in forum Qt Programming
    Replies: 6
    Last Post: 8th April 2006, 10:08

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.