Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-919

Exception handling in eventloop code makes it difficult to debug stack overflows

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • Some future release
    • None
    • Core: Event loop
    • None

    Description

      Clicking on this widget crashes:

      #include <QtGui>

      class MyWidget : public QWidget
      {
      public:
      MyWidget()
      { }

      protected:
      void mousePressEvent(QMouseEvent *event)

      { // do something MyWidget::mousePressEvent(event); // ups, typo }

      };

      int main(int argc, char **argv)
      {
      QApplication a(argc, argv);
      MyWidget stackOverflow;
      stackOverflow.show();
      return a.exec();
      }

      The reason is obvious when getting a decent stack trace:

      MyWidget::mousePressEvent(QMouseEvent * 0x0012c560

      {type="MouseButtonPress"}) line 14
      MyWidget::mousePressEvent(QMouseEvent * 0x0012c560 {type="MouseButtonPress"}

      ) line 14
      MyWidget::mousePressEvent(QMouseEvent * 0x0012c560

      {type="MouseButtonPress"}) line 14
      MyWidget::mousePressEvent(QMouseEvent * 0x0012c560 {type="MouseButtonPress"}

      ) line 14
      MyWidget::mousePressEvent(QMouseEvent * 0x0012c560

      {type="MouseButtonPress"}

      ) line 14
      [...]

      but due the exception handling in QEventLoop::exec, the stack trace is instead

      $$$00001() line 79
      QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag>

      {...}

      ) line 166 + 10 bytes
      QCoreApplication::exec() line 727 + 21 bytes
      QApplication::exec() line 3031
      main(int 1, char * * 0x009e62c0) line 22 + 6 bytes
      WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00141f09, int 1) line 95 + 18 bytes
      WinMainCRTStartup() line 330 + 54 bytes
      KERNEL32! 7c816fd7()

      The only thing that points the the stack overflow is the debugger pane saying:

      First-chance exception in sandbox43.exe: 0xC00000FD: Stack Overflow.
      First-chance exception in sandbox43.exe (QTCORED4.DLL): 0xC0000005: Access Violation.

      It's hard to know where the stack overflow occurs though. Maybe a debug build of Qt should not use the try/catch.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sorvig Morten Sørvig
            vhilshei Volker Hilsheimer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes