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. App crashes after close and window destruction [MSVC2017 x86]

App crashes after close and window destruction [MSVC2017 x86]

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.5k Views
  • 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.
  • E Offline
    E Offline
    Elnee
    wrote on last edited by Elnee
    #1

    I'm using Qt 5.13.0. Can somebody help to find what cause next error. For me it looks like use after free but what tools I can use to find problem in code.

    Maybe next bug is related to the problem but I haven't any ideas how to fix it: https://bugreports.qt.io/browse/QTBUG-39227

    Stack trace:

    qwindowsd.dll!QScopedPointer<QWindowsContextPrivate,QScopedPointerDeleter<QWindowsContextPrivate> >::operator->() Line 118	C++
    qwindowsd.dll!QWindowsContext::windowUnderMouse() Line 686	C++
    qwindowsd.dll!QWindowsWindow::destroyWindow() Line 1284	C++
    qwindowsd.dll!QWindowsWindow::~QWindowsWindow() Line 1235	C++
    [External Code]	
    Qt5Guid.dll!QWindowPrivate::destroy() Line 1920	C++
    Qt5Guid.dll!QWindow::destroy() Line 1870	C++
    Qt5Widgetsd.dll!QWidgetPrivate::deleteTLSysExtra() Line 1903	C++
    Qt5Widgetsd.dll!QWidget::destroy(bool destroyWindow, bool destroySubWindows) Line 12497	C++
    Qt5Widgetsd.dll!QWidget::~QWidget() Line 1717	C++
    Qt5Widgetsd.dll!QFrame::~QFrame() Line 264	C++
    [External Code]	
    Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
    Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
    Qt5Widgetsd.dll!QComboBox::~QComboBox() Line 1420	C++
    [External Code]	
    Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
    Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
    Qt5Widgetsd.dll!QGroupBox::~QGroupBox() Line 203	C++
    [External Code]	
    Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
    Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
    arm_auto_1.0.4.exe!AbstractSettingsWidget::~AbstractSettingsWidget() Line 12	C++
    arm_auto_1.0.4.exe!WeightProcessor::~WeightProcessor() Line 24	C++
    [External Code]	
    Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
    Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
    Qt5Widgetsd.dll!QFrame::~QFrame() Line 264	C++
    Qt5Widgetsd.dll!QStackedWidget::~QStackedWidget() Line 147	C++
    [External Code]	
    Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
    Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
    Qt5Widgetsd.dll!QTabWidget::~QTabWidget() Line 373	C++
    [External Code]	
    Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
    Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
    [External Code]	
    Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
    Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
    Qt5Widgetsd.dll!QFrame::~QFrame() Line 264	C++
    Qt5Widgetsd.dll!QStackedWidget::~QStackedWidget() Line 147	C++
    [External Code]	
    Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
    Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
    Qt5Widgetsd.dll!QTabWidget::~QTabWidget() Line 373	C++
    [External Code]	
    Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
    Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
    Qt5Widgetsd.dll!QDialog::~QDialog() Line 427	C++
    arm_auto_1.0.4.exe!SettingsForm::~SettingsForm() Line 86	C++
    [External Code]	
    arm_auto_1.0.4.exe!MainWindow::~MainWindow() Line 5271	C++
    [External Code]	
    [Frames below may be incorrect and/or missing, no symbols loaded for ucrtbased.dll]	Unknown
    
    

    0_1565701290195_Untitled.png

    Pablo J. RoginaP 1 Reply Last reply
    1
    • E Elnee

      I'm using Qt 5.13.0. Can somebody help to find what cause next error. For me it looks like use after free but what tools I can use to find problem in code.

      Maybe next bug is related to the problem but I haven't any ideas how to fix it: https://bugreports.qt.io/browse/QTBUG-39227

      Stack trace:

      qwindowsd.dll!QScopedPointer<QWindowsContextPrivate,QScopedPointerDeleter<QWindowsContextPrivate> >::operator->() Line 118	C++
      qwindowsd.dll!QWindowsContext::windowUnderMouse() Line 686	C++
      qwindowsd.dll!QWindowsWindow::destroyWindow() Line 1284	C++
      qwindowsd.dll!QWindowsWindow::~QWindowsWindow() Line 1235	C++
      [External Code]	
      Qt5Guid.dll!QWindowPrivate::destroy() Line 1920	C++
      Qt5Guid.dll!QWindow::destroy() Line 1870	C++
      Qt5Widgetsd.dll!QWidgetPrivate::deleteTLSysExtra() Line 1903	C++
      Qt5Widgetsd.dll!QWidget::destroy(bool destroyWindow, bool destroySubWindows) Line 12497	C++
      Qt5Widgetsd.dll!QWidget::~QWidget() Line 1717	C++
      Qt5Widgetsd.dll!QFrame::~QFrame() Line 264	C++
      [External Code]	
      Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
      Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
      Qt5Widgetsd.dll!QComboBox::~QComboBox() Line 1420	C++
      [External Code]	
      Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
      Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
      Qt5Widgetsd.dll!QGroupBox::~QGroupBox() Line 203	C++
      [External Code]	
      Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
      Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
      arm_auto_1.0.4.exe!AbstractSettingsWidget::~AbstractSettingsWidget() Line 12	C++
      arm_auto_1.0.4.exe!WeightProcessor::~WeightProcessor() Line 24	C++
      [External Code]	
      Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
      Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
      Qt5Widgetsd.dll!QFrame::~QFrame() Line 264	C++
      Qt5Widgetsd.dll!QStackedWidget::~QStackedWidget() Line 147	C++
      [External Code]	
      Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
      Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
      Qt5Widgetsd.dll!QTabWidget::~QTabWidget() Line 373	C++
      [External Code]	
      Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
      Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
      [External Code]	
      Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
      Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
      Qt5Widgetsd.dll!QFrame::~QFrame() Line 264	C++
      Qt5Widgetsd.dll!QStackedWidget::~QStackedWidget() Line 147	C++
      [External Code]	
      Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
      Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
      Qt5Widgetsd.dll!QTabWidget::~QTabWidget() Line 373	C++
      [External Code]	
      Qt5Cored.dll!QObjectPrivate::deleteChildren() Line 2019	C++
      Qt5Widgetsd.dll!QWidget::~QWidget() Line 1710	C++
      Qt5Widgetsd.dll!QDialog::~QDialog() Line 427	C++
      arm_auto_1.0.4.exe!SettingsForm::~SettingsForm() Line 86	C++
      [External Code]	
      arm_auto_1.0.4.exe!MainWindow::~MainWindow() Line 5271	C++
      [External Code]	
      [Frames below may be incorrect and/or missing, no symbols loaded for ucrtbased.dll]	Unknown
      
      

      0_1565701290195_Untitled.png

      Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @elnee could you please show your code? where the issue actually appears...

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      E 1 Reply Last reply
      1
      • Pablo J. RoginaP Pablo J. Rogina

        @elnee could you please show your code? where the issue actually appears...

        E Offline
        E Offline
        Elnee
        wrote on last edited by
        #3

        @pablo-j-rogina thank you for answer. Exactly code where crash appears is on screen. In call stack there are three main points: ~MainWindow() destructor, ~SettingsForm() destructor and ~WeightProcessor() destructor. It crashes only after close. And it looks like someone trying to access window or form, that was destructured, but I'm not sure. I need a tool to find that place in code, because code base is pretty big. Also from call stack it's obvious that app crashes when dereferencing QScopedPointer with template parameter QWindowsContextPrivate.

        J.HilkJ Pablo J. RoginaP 2 Replies Last reply
        0
        • E Elnee

          @pablo-j-rogina thank you for answer. Exactly code where crash appears is on screen. In call stack there are three main points: ~MainWindow() destructor, ~SettingsForm() destructor and ~WeightProcessor() destructor. It crashes only after close. And it looks like someone trying to access window or form, that was destructured, but I'm not sure. I need a tool to find that place in code, because code base is pretty big. Also from call stack it's obvious that app crashes when dereferencing QScopedPointer with template parameter QWindowsContextPrivate.

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @elnee It's technically where your app crashes, but you can go back in the trace to where your last own class was used. If you're using QtCreator you can simply double click on it and the correct file & position will be shown.

          Should help narrowing the issue down


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          E 1 Reply Last reply
          1
          • J.HilkJ J.Hilk

            @elnee It's technically where your app crashes, but you can go back in the trace to where your last own class was used. If you're using QtCreator you can simply double click on it and the correct file & position will be shown.

            Should help narrowing the issue down

            E Offline
            E Offline
            Elnee
            wrote on last edited by Elnee
            #5

            @j-hilk thank you for answer. I found more information. It crashes in QWindowsWindow::destroyWindow() when trying to destroy top level window QWindowsContext::instance() returns nullptr and then crash appears on 1284 line in dereferencing context pointer that is nullptr. Any ideas what can cause that kind of behavior? Why QWindowsContext::instance() returns nullptr. How can I address an issue?

            0_1565765374320_QWindowsContext.PNG

            1 Reply Last reply
            1
            • E Elnee

              @pablo-j-rogina thank you for answer. Exactly code where crash appears is on screen. In call stack there are three main points: ~MainWindow() destructor, ~SettingsForm() destructor and ~WeightProcessor() destructor. It crashes only after close. And it looks like someone trying to access window or form, that was destructured, but I'm not sure. I need a tool to find that place in code, because code base is pretty big. Also from call stack it's obvious that app crashes when dereferencing QScopedPointer with template parameter QWindowsContextPrivate.

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @elnee said in App crashes after close and window destruction [MSVC2017 x86]:

              ~SettingsForm() destructor and ~WeightProcessor() destructor

              I was asking for your actual code since sometimes it's easier to spot that a Qt object is not a children of some other Qt children and you're losing benefit of the automatic destroy feature of Qt, just to mention one case.

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • E Offline
                E Offline
                Elnee
                wrote on last edited by
                #7

                Thank you all for answers. I found the main cause of problem. MainWindow in that application is Singleton, so it destroys after QApplication destroyed. Yeah, it's a legacy code. So I just added post-routine to QApplication via qAddPostRoutine() to ensure that MainWindow is destroyed before QApplication.

                1 Reply Last reply
                3

                • Login

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