Results 1 to 3 of 3

Thread: QMap <QString, QString> deleting and RtlValidateHeap exception

  1. #1
    Join Date
    Jan 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default QMap <QString, QString> deleting and RtlValidateHeap exception

    Hi.
    I am faced with the strange behavior, which is occurs when removing QMap <QString, QString>:
    Qt Code:
    1. QFile file("some.xml");
    2.  
    3. if (file.open(QIODevice::ReadOnly))
    4. {
    5. QByteArray data = file.readAll();
    6.  
    7. QDomDocument domDoc;
    8. QMap<QString,QString> nodeMap;
    9. if (domDoc.setContent( data ))
    10. {
    11. QDomNode topNode = domDoc.documentElement().firstChild();
    12. while ( !topNode.isNull()) {
    13. nodeMap.insert( topNode.toElement().tagName(), topNode.toElement().text() );
    14. topNode = topNode.nextSibling();
    15. }
    16. }
    17. qDebug() << nodeMap;
    18. }
    19. // <- Right here, after the local variable nodeMap was deleted from stack, I getting the exception RtlValidateHeap
    To copy to clipboard, switch view to plain text mode 

    Here is Call Stack when RtlValidateHeap exception is happening:

    ntdll.dll!RtlpNtEnumerateSubKey() + 0x3947 byte
    ntdll.dll!RtlUlonglongByteSwap() + 0x1561a byte
    ntdll.dll!RtlValidateHeap() + 0x7a byte
    KernelBase.dll!HeapValidate() + 0x14 byte
    > msvcr100d.dll!_CrtIsValidHeapPointer(const void * pUserData) Line 2036 C++
    msvcr100d.dll!_free_dbg_nolock(void * pUserData, int nBlockUse) Line 1322 + 0x9 byte C++
    msvcr100d.dll!_free_dbg(void * pUserData, int nBlockUse) Line 1265 + 0xd byte C++
    msvcr100d.dll!free(void * pUserData) Line 49 + 0xb byte C++
    Qt5Cored.dll!QByteArray:: operator>=() + 0x7db14 byte
    Qt5Cored.dll!QByteArray:: operator>=() + 0x17b77 byte
    Qt5Cored.dll!QByteArray:: operator>=() + 0x14fea byte
    MyApp.exe!QString::`scalar deleting destructor'() + 0x10 byte C++
    MyApp.exe!QMapNode<QString,QString>::destroySubTre e() Line 261 C++
    MyApp.exe!QMapData<QString,QString>::destroy() Line 223 C++
    MyApp.exe!QMap<QString,QString>::~QMap<QString,QSt ring>() Line 339 + 0x22 byte C++
    MyApp.exe!QMap<QString,QString>::`scalar deleting destructor'() + 0xf byte C++
    MyApp.exe!main(int argc, char * * argv) Line 49 + 0x2e byte C++
    MyApp.exe!WinMain(HINSTANCE__ * __formal, HINSTANCE__ * __formal, HINSTANCE__ * __formal, HINSTANCE__ * __formal) Line 113 + 0xd byte C++
    MyApp.exe!__tmainCRTStartup() Line 547 + 0x2c byte C
    MyApp.exe!WinMainCRTStartup() Line 371 C
    kernel32.dll!BaseThreadInitThunk() + 0x12 byte
    ntdll.dll!RtlInitializeExceptionChain() + 0x63 byte
    ntdll.dll!RtlInitializeExceptionChain() + 0x36 byte
    It looks like an double delete or access to the dangling pointers in QByteArray:: operator>=(), but I can't figure out how to solve this problem.

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QMap <QString, QString> deleting and RtlValidateHeap exception

    I cannot see any obvious corruption of the heap in this snippet of code; it may be in another part of the program.

    By the way, your code calls topNode.toElement() without checking that topNode is an element.

  3. #3
    Join Date
    Jan 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QMap <QString, QString> deleting and RtlValidateHeap exception

    Problem was in the project settings - under debug version of the project, was set load QtXml.dll instead of QtXmld.dll.

Similar Threads

  1. Replies: 3
    Last Post: 27th December 2013, 18:04
  2. Replies: 3
    Last Post: 27th July 2012, 09:30
  3. Replies: 2
    Last Post: 11th August 2011, 15:42
  4. QMAP<QString, QStringList>
    By bismitapadhy in forum Qt Programming
    Replies: 3
    Last Post: 4th February 2010, 04:47
  5. Replies: 4
    Last Post: 31st January 2008, 20:44

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
  •  
Qt is a trademark of The Qt Company.