Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why does even a basic QTreeWidget app crash on QTreeWidget::clear() ???
Forum Updated to NodeBB v4.3 + New Features

Why does even a basic QTreeWidget app crash on QTreeWidget::clear() ???

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 4 Posters 6.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #3

    @jsulm
    Hi,
    When building the Release version of the basic example above, no error.
    The Debug build fails with the following error:

    HEAP[test.exe]: Invalid address specified to RtlValidateHeap( 0000000000090000, 00000000000EBE70 )

    The stack trace is as follows (arrow at line 13):

    1  EtwpCreateEtwThread                              ntdll                               0x77d19e51    
    2  EtwEventSetInformation                           ntdll                               0x77cf6965    
    3  RtlValidateHeap                                  ntdll                               0x77c8ec51    
    4  HeapValidate                                     KERNELBASE                          0x7fefdb6304a 
    5  CrtIsValidHeapPointer                            ucrtbased                           0x7fedf02d911 
    6  calloc_base                                      ucrtbased                           0x7fedf02bcb9 
    7  free_dbg                                         ucrtbased                           0x7fedf02f305 
    8  operator delete                                  delete_scalar.cpp              21   0x13f825388   
    9  operator delete                                  delete_scalar_size.cpp         16   0x13f824a78   
    10 QTreeWidgetItem::`scalar deleting destructor'    test                                0x13f822fa2   
    11 QTreeModel::clear                                qtreewidget.cpp                169  0x61b28c5a    
    12 QTreeWidget::clear                               qtreewidget.cpp                3252 0x61b27719    
    13 MainWindow::on_pushButton_2_clicked              mainwindow.cpp                 30   0x13f82366c   
    14 MainWindow::qt_static_metacall                   moc_mainwindow.cpp             81   0x13f8243b6   
    15 MainWindow::qt_metacall                          moc_mainwindow.cpp             110  0x13f824307   
    16 QMetaObject::metacall                            qmetaobject.cpp                302  0x60e0df44    
    17 QMetaObject::activate                            qobject.cpp                    3783 0x60e55e04    
    18 QMetaObject::activate                            qobject.cpp                    3629 0x60e55488    
    19 QAbstractButton::clicked                         moc_qabstractbutton.cpp        310  0x6194877d    
    20 QAbstractButtonPrivate::emitClicked              qabstractbutton.cpp            412  0x6194a8b4    
    21 QAbstractButtonPrivate::click                    qabstractbutton.cpp            404  0x61949977    
    22 QAbstractButton::mouseReleaseEvent               qabstractbutton.cpp            1007 0x61948f37    
    23 QWidget::event                                   qwidget.cpp                    8799 0x6163695d    
    24 QAbstractButton::event                           qabstractbutton.cpp            965  0x619489cb    
    25 QPushButton::event                               qpushbutton.cpp                684  0x61966011    
    26 QApplicationPrivate::notify_helper               qapplication.cpp               3717 0x615d6f3e    
    27 QApplication::notify                             qapplication.cpp               3193 0x615d217c    
    28 QCoreApplication::notifyInternal2                qcoreapplication.cpp           1018 0x60dff666    
    29 QCoreApplication::sendSpontaneousEvent           qcoreapplication.h             236  0x60f65cbb    
    30 QApplicationPrivate::sendMouseEvent              qapplication.cpp               2697 0x615d9633    
    31 QWidgetWindow::handleMouseEvent                  qwidgetwindow.cpp              623  0x61680e37    
    32 QWidgetWindow::event                             qwidgetwindow.cpp              244  0x6167f60a    
    33 QApplicationPrivate::notify_helper               qapplication.cpp               3717 0x615d6f3e    
    34 QApplication::notify                             qapplication.cpp               3089 0x615d1973    
    35 QCoreApplication::notifyInternal2                qcoreapplication.cpp           1018 0x60dff666    
    36 QCoreApplication::sendSpontaneousEvent           qcoreapplication.h             236  0x60f65cbb    
    37 QGuiApplicationPrivate::processMouseEvent        qguiapplication.cpp            1950 0x7fedd88c19a 
    38 QGuiApplicationPrivate::processWindowSystemEvent qguiapplication.cpp            1734 0x7fedd88ed13 
    39 QWindowSystemInterface::sendWindowSystemEvents   qwindowsysteminterface.cpp     945  0x7fedd849a45 
    40 QWindowsGuiEventDispatcher::sendPostedEvents     qwindowsguieventdispatcher.cpp 83   0x7feded2fe82 
    41 qt_internal_proc                                 qeventdispatcher_win.cpp       236  0x60ebad0d    
    42 TranslateMessageEx                               USER32                              0x77a69bbd    
    43 TranslateMessage                                 USER32                              0x77a698c2    
    44 QEventDispatcherWin32::processEvents             qeventdispatcher_win.cpp       627  0x60ebb71b    
    45 QWindowsGuiEventDispatcher::processEvents        qwindowsguieventdispatcher.cpp 74   0x7feded2fe34 
    46 QEventLoop::processEvents                        qeventloop.cpp                 135  0x60df9a38    
    47 QEventLoop::exec                                 qeventloop.cpp                 212  0x60df9c7e    
    48 QCoreApplication::exec                           qcoreapplication.cpp           1291 0x60dfd30f    
    49 QGuiApplication::exec                            qguiapplication.cpp            1680 0x7fedd8896f8 
    50 QApplication::exec                               qapplication.cpp               2906 0x615d147a    
    51 main                                             main.cpp                       10   0x13f8224b9   
    52 WinMain                                          qtmain_win.cpp                 104  0x13f8271ed   
    53 invoke_main                                      exe_common.inl                 109  0x13f824ecd   
    54 __scrt_common_main_seh                           exe_common.inl                 264  0x13f824d6e   
    55 __scrt_common_main                               exe_common.inl                 309  0x13f824c2e   
    56 WinMainCRTStartup                                exe_winmain.cpp                17   0x13f824ee9   
    57 BaseThreadInitThunk                              kernel32                            0x77b659cd    
    58 RtlUserThreadStart                               ntdll                               0x77c9a561    
    

    Maybe this problem with the Debug builds is related to my previous post?:
    Do all Qt Debugging sessions end with "Invalid address specified to RtlValidateHeap" error?

    1 Reply Last reply
    0
    • jsulmJ jsulm

      @Diracsbracket Can you show the stack trace when it crashes?

      DiracsbracketD Offline
      DiracsbracketD Offline
      Diracsbracket
      wrote on last edited by
      #4

      @jsulm
      It turns out that on my Windows 7 machine, Qt 5.9.1 ALWAYS crashes in Debug mode when the program reaches a delete instruction, no matter which example I try.

      1 Reply Last reply
      0
      • DiracsbracketD Offline
        DiracsbracketD Offline
        Diracsbracket
        wrote on last edited by
        #5

        I submitted this as a bug
        https://bugreports.qt.io/browse/QTCREATORBUG-19007

        A 1 Reply Last reply
        0
        • DiracsbracketD Diracsbracket

          I submitted this as a bug
          https://bugreports.qt.io/browse/QTCREATORBUG-19007

          A Offline
          A Offline
          ambershark
          wrote on last edited by ambershark
          #6

          @Diracsbracket I highly doubt this is an issue with Qt, so submitting as a bug will just end in it being non-reproducible.

          It almost sounds like you have a bad version of ntdll. My guess would be that you have some bad software/update from MS on your system.

          It could be some other piece of software you have interfering too. A virus checker perhaps? SpyBot seems to cause an issue like this based on some light searching I did.

          If you try this same thing on a virtual machine with windows 7 it should work perfectly. Finding what is causing it is a much bigger challenge than I'm able to tackle remotely though. :)

          And it most definitely is the same problem you mentioned in your other thread.

          My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

          DiracsbracketD 1 Reply Last reply
          1
          • A ambershark

            @Diracsbracket I highly doubt this is an issue with Qt, so submitting as a bug will just end in it being non-reproducible.

            It almost sounds like you have a bad version of ntdll. My guess would be that you have some bad software/update from MS on your system.

            It could be some other piece of software you have interfering too. A virus checker perhaps? SpyBot seems to cause an issue like this based on some light searching I did.

            If you try this same thing on a virtual machine with windows 7 it should work perfectly. Finding what is causing it is a much bigger challenge than I'm able to tackle remotely though. :)

            And it most definitely is the same problem you mentioned in your other thread.

            DiracsbracketD Offline
            DiracsbracketD Offline
            Diracsbracket
            wrote on last edited by
            #7

            @ambershark
            Thanks. It seems no one else is complaining about this, so it must be my system... If it gets solved, I'll post an update.

            A 1 Reply Last reply
            0
            • DiracsbracketD Diracsbracket

              @ambershark
              Thanks. It seems no one else is complaining about this, so it must be my system... If it gets solved, I'll post an update.

              A Offline
              A Offline
              ambershark
              wrote on last edited by
              #8

              @Diracsbracket An easy test would be to setup a virtualbox vm with a fresh windows and install Qt. Then test your app in there. If it works then you know it's a problem on your system with something you have installed. If it does it there too, there may be more to it. Maybe hardware, or maybe there is a legit Qt bug.

              That would be a major bug though and would definitely have been caught before release. It would also affect all of us and not just you.

              My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

              DiracsbracketD 1 Reply Last reply
              1
              • A ambershark

                @Diracsbracket An easy test would be to setup a virtualbox vm with a fresh windows and install Qt. Then test your app in there. If it works then you know it's a problem on your system with something you have installed. If it does it there too, there may be more to it. Maybe hardware, or maybe there is a legit Qt bug.

                That would be a major bug though and would definitely have been caught before release. It would also affect all of us and not just you.

                DiracsbracketD Offline
                DiracsbracketD Offline
                Diracsbracket
                wrote on last edited by Diracsbracket
                #9

                @ambershark
                Exactly. That's why I am gonna put this post to "Solved". I don't really have the time right now to setup another VM with Windows 7 + Qt Creator + Visual Studio, but I'll give it a try in my Windows 10 VM, although it's a different environment altogether.
                Cheers!

                1 Reply Last reply
                1
                • DiracsbracketD Offline
                  DiracsbracketD Offline
                  Diracsbracket
                  wrote on last edited by
                  #10

                  Update: tried in a Windows 10 VM. Same error. Debugging just does not work.
                  Installed Visual Studio 2015, Qt 5.9.1, and SDK kit 10 for the debugging tools.

                  What a WASTE of time!!!!

                  A 1 Reply Last reply
                  0
                  • DiracsbracketD Diracsbracket

                    Update: tried in a Windows 10 VM. Same error. Debugging just does not work.
                    Installed Visual Studio 2015, Qt 5.9.1, and SDK kit 10 for the debugging tools.

                    What a WASTE of time!!!!

                    A Offline
                    A Offline
                    ambershark
                    wrote on last edited by
                    #11

                    @Diracsbracket Well it wasn't a waste of time since it gave you more information about the problem. So if you set up a fresh windows vm and still had the issue then it is something to do with what you are installing in the vm.

                    What software did you install in your fresh environment? Exact list.

                    Also have you tried with a different Qt version, maybe a bug was introduced in 5.9.1, although I doubt something that major would have made it through QA.

                    One more thing too, have you tried using a model instead of parenting QTreeWidgetItem's to the tree? You can use a QStandardItemModel which should do the same thing you are doing. See if the crash is still there. This is a stretch though since it's only in debug it's unlikely there is an issue here.

                    Tomorrow when I have time I'll try to throw your code into a quick test app and see if it crashes for me.

                    My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                    1 Reply Last reply
                    0
                    • DiracsbracketD Offline
                      DiracsbracketD Offline
                      Diracsbracket
                      wrote on last edited by Diracsbracket
                      #12

                      The problem I am facing is not limited to the simple QTreeWidget example I posted, but with every standard Qt example, always at some delete operation.

                      I have tried installing the latest Windows Kit 10 release (10.0.16299.15) with the new cdb.exe, whose version is wrongly reported by Qt Creator (when mouse hovering over the file, the tooltip shows the correct version, but the text field of Qt Creator remains wrong, even after restart of PC). The new Kit release does not solve the problem.

                      Now, I am installing Qt 5.9.2, which as you know, takes some time... even at 1.5 MB/s ...

                      JonBJ 1 Reply Last reply
                      0
                      • DiracsbracketD Diracsbracket

                        The problem I am facing is not limited to the simple QTreeWidget example I posted, but with every standard Qt example, always at some delete operation.

                        I have tried installing the latest Windows Kit 10 release (10.0.16299.15) with the new cdb.exe, whose version is wrongly reported by Qt Creator (when mouse hovering over the file, the tooltip shows the correct version, but the text field of Qt Creator remains wrong, even after restart of PC). The new Kit release does not solve the problem.

                        Now, I am installing Qt 5.9.2, which as you know, takes some time... even at 1.5 MB/s ...

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by
                        #13

                        @Diracsbracket

                        • Are you building the (debug) Qt from the sources yourself?

                        • What happens if you run the debug-built app outside of Qt Creator/debugger, e.g. from command-line?

                        DiracsbracketD 1 Reply Last reply
                        0
                        • JonBJ JonB

                          @Diracsbracket

                          • Are you building the (debug) Qt from the sources yourself?

                          • What happens if you run the debug-built app outside of Qt Creator/debugger, e.g. from command-line?

                          DiracsbracketD Offline
                          DiracsbracketD Offline
                          Diracsbracket
                          wrote on last edited by Diracsbracket
                          #14

                          @JNBarchan
                          I am not using a self-built version of Qt Creator, just using the official windows installer.

                          I just now uninstalled all of Qt, and installed 5.9.2... And of course, I get errors which I didn't have before:

                          D:\Qt\5.9.2\msvc2015_64\include\QtCore\qt_windows.h:64: error: C1083: Cannot open include file: 'windows.h': No such file or directory
                          

                          Qt is just great...

                          jsulmJ 1 Reply Last reply
                          0
                          • DiracsbracketD Diracsbracket

                            @JNBarchan
                            I am not using a self-built version of Qt Creator, just using the official windows installer.

                            I just now uninstalled all of Qt, and installed 5.9.2... And of course, I get errors which I didn't have before:

                            D:\Qt\5.9.2\msvc2015_64\include\QtCore\qt_windows.h:64: error: C1083: Cannot open include file: 'windows.h': No such file or directory
                            

                            Qt is just great...

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #15

                            @Diracsbracket said in Why does even a basic QTreeWidget app crash on QTreeWidget::clear() ???:

                            Qt is just great...

                            It is.
                            After installing Qt did you delete the build folder, run qmake and rebuild?

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            DiracsbracketD 1 Reply Last reply
                            0
                            • jsulmJ jsulm

                              @Diracsbracket said in Why does even a basic QTreeWidget app crash on QTreeWidget::clear() ???:

                              Qt is just great...

                              It is.
                              After installing Qt did you delete the build folder, run qmake and rebuild?

                              DiracsbracketD Offline
                              DiracsbracketD Offline
                              Diracsbracket
                              wrote on last edited by
                              #16

                              @jsulm Yes...

                              1 Reply Last reply
                              0
                              • DiracsbracketD Offline
                                DiracsbracketD Offline
                                Diracsbracket
                                wrote on last edited by Diracsbracket
                                #17

                                I finally got the debugging working again. I have no solution, because I still don't know what the cause of my problems was, but I reinstalled Qt 5.9.1, uninstalled VS2015 and reinstalled it. And now debugging works again. Moreover, I no longer need have the following lines in my .pro files:

                                 INCLUDEPATH += "C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\ucrt"
                                 LIBS += "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64\ucrt.lib"
                                 LIBS += "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64\ucrtd.lib"
                                

                                I needed to add those lines in every .pro file of my earlier install, otherwise none of the Qt examples nor my program would build. That probably was already an indication that there was something wrong with my installation and why I couldn't debug. Now, my little program (and I guess all the Qt examples too) builds without those lines.

                                Cheers to all who tried to help!

                                JonBJ A 2 Replies Last reply
                                1
                                • DiracsbracketD Diracsbracket

                                  I finally got the debugging working again. I have no solution, because I still don't know what the cause of my problems was, but I reinstalled Qt 5.9.1, uninstalled VS2015 and reinstalled it. And now debugging works again. Moreover, I no longer need have the following lines in my .pro files:

                                   INCLUDEPATH += "C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\ucrt"
                                   LIBS += "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64\ucrt.lib"
                                   LIBS += "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64\ucrtd.lib"
                                  

                                  I needed to add those lines in every .pro file of my earlier install, otherwise none of the Qt examples nor my program would build. That probably was already an indication that there was something wrong with my installation and why I couldn't debug. Now, my little program (and I guess all the Qt examples too) builds without those lines.

                                  Cheers to all who tried to help!

                                  JonBJ Offline
                                  JonBJ Offline
                                  JonB
                                  wrote on last edited by
                                  #18

                                  @Diracsbracket said in Why does even a basic QTreeWidget app crash on QTreeWidget::clear() ???:

                                  I finally got the debugging working again. I have no solution, because I still don't know what the cause of my problems was,

                                  If you played with the versions of the C runtime libraries, but did not think to mention it, do you not think that might be related to why it falls over in delete calling calloc calling HeapValidate?

                                  I wouldn't read much into it crashing until you are 100% sure your libraries --- Debug-or-not --- are definitely all correct & consistent across everything you're doing. Personally.

                                  DiracsbracketD 1 Reply Last reply
                                  1
                                  • DiracsbracketD Diracsbracket

                                    I finally got the debugging working again. I have no solution, because I still don't know what the cause of my problems was, but I reinstalled Qt 5.9.1, uninstalled VS2015 and reinstalled it. And now debugging works again. Moreover, I no longer need have the following lines in my .pro files:

                                     INCLUDEPATH += "C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\ucrt"
                                     LIBS += "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64\ucrt.lib"
                                     LIBS += "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64\ucrtd.lib"
                                    

                                    I needed to add those lines in every .pro file of my earlier install, otherwise none of the Qt examples nor my program would build. That probably was already an indication that there was something wrong with my installation and why I couldn't debug. Now, my little program (and I guess all the Qt examples too) builds without those lines.

                                    Cheers to all who tried to help!

                                    A Offline
                                    A Offline
                                    ambershark
                                    wrote on last edited by
                                    #19

                                    @Diracsbracket said in Why does even a basic QTreeWidget app crash on QTreeWidget::clear() ???:

                                    I finally got the debugging working again. I have no solution, because I still don't know what the cause of my problems was, but I reinstalled Qt 5.9.1, uninstalled VS2015 and reinstalled it. And now debugging works again. Moreover, I no longer need have the following lines in my .pro files:

                                     INCLUDEPATH += "C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\ucrt"
                                     LIBS += "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64\ucrt.lib"
                                     LIBS += "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64\ucrtd.lib"
                                    

                                    I needed to add those lines in every .pro file of my earlier install, otherwise none of the Qt examples nor my program would build. That probably was already an indication that there was something wrong with my installation and why I couldn't debug. Now, my little program (and I guess all the Qt examples too) builds without those lines.

                                    Cheers to all who tried to help!

                                    Lol this would have been great to know at the beginning. You did something very wrong with your environment or install if you had to do this. And of course you were then mixing C runtimes which of course is not ok, as you found out. I'm surprised all you did was crash on delete to be honest. It should have been much worse.

                                    Oh well, you learned something which is the whole point of these forums. :) Glad you got it fixed.

                                    My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                                    1 Reply Last reply
                                    3
                                    • JonBJ JonB

                                      @Diracsbracket said in Why does even a basic QTreeWidget app crash on QTreeWidget::clear() ???:

                                      I finally got the debugging working again. I have no solution, because I still don't know what the cause of my problems was,

                                      If you played with the versions of the C runtime libraries, but did not think to mention it, do you not think that might be related to why it falls over in delete calling calloc calling HeapValidate?

                                      I wouldn't read much into it crashing until you are 100% sure your libraries --- Debug-or-not --- are definitely all correct & consistent across everything you're doing. Personally.

                                      DiracsbracketD Offline
                                      DiracsbracketD Offline
                                      Diracsbracket
                                      wrote on last edited by
                                      #20

                                      @JNBarchan said in Why does even a basic QTreeWidget app crash on QTreeWidget::clear() ???:

                                      If you played with the versions of the C runtime libraries, but did not think to mention it, do you not think that might be related to why it falls over in delete calling calloc calling HeapValidate?

                                      I added those lines because after installing Qt Creator and selecting the auto-detected compilers etc..., it would not build because of some crt header file not being found. A proposed solution I found on the web was to add those lines in the .pro file, which seemed to work, at least for the release builds. That's why.

                                      JonBJ 1 Reply Last reply
                                      0
                                      • DiracsbracketD Diracsbracket

                                        @JNBarchan said in Why does even a basic QTreeWidget app crash on QTreeWidget::clear() ???:

                                        If you played with the versions of the C runtime libraries, but did not think to mention it, do you not think that might be related to why it falls over in delete calling calloc calling HeapValidate?

                                        I added those lines because after installing Qt Creator and selecting the auto-detected compilers etc..., it would not build because of some crt header file not being found. A proposed solution I found on the web was to add those lines in the .pro file, which seemed to work, at least for the release builds. That's why.

                                        JonBJ Offline
                                        JonBJ Offline
                                        JonB
                                        wrote on last edited by
                                        #21

                                        @Diracsbracket
                                        I don't dispute that you (felt you) had whatever reason to add the stuff. But as @ambershark & I observed, when you come reporting a heap crash in a post entitled "Why does even a basic QTreeWidget app crash on QTreeWidget::clear() ???", you have to let us know that your "basic QTreeWidget" was generated using a system where you had to tinker with compiler/linker settings from the default as that is 100% germane....

                                        1 Reply Last reply
                                        2

                                        • Login

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • Users
                                        • Groups
                                        • Search
                                        • Get Qt Extensions
                                        • Unsolved