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. Crash on exit when QMessageBox was used
Qt 6.11 is out! See what's new in the release blog

Crash on exit when QMessageBox was used

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 3.1k 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.
  • AndreasLubenskyA Offline
    AndreasLubenskyA Offline
    AndreasLubensky
    wrote on last edited by
    #1

    Hi,
    I'm trying to figure out a crash that occurs when I'm closing an application. The main window handles the close event and opens a QMessageBox to ask the user if he really wants to shut down.
    Now, the application crashes in the destruction of the QApplication.
    If I don't use the message box, the program shuts down nicely.

    I assembled a small test program to replicate the problem:

    #include <QMainWindow>
    #include <QApplication>
    #include <QMessageBox>
    #include <QCloseEvent>
    
    class MyMainWindow : public QMainWindow {
    protected:
      void closeEvent( QCloseEvent* e) {
        if( QMessageBox::question( this, "foo", "bar") == QMessageBox::Yes) {
          e->accept();
        } else {
          e->ignore();
        }
      }
    };
    
    int main( int argc, char** argv) {
      QApplication app( argc, argv);
    
      MyMainWindow window;
      window.show();
    
      return app.exec();
    }
    

    The call stack can differ, but this would be one example:

    #0  0x00007fffe843f195 in malloc_consolidate () from /lib64/libc.so.6
    #1  0x00007fffe843fd31 in _int_free () from /lib64/libc.so.6
    #2  0x00007ffff5cb3862 in ?? () from /usr/lib64/libQt5Gui.so.5
    #3  0x00007ffff6c336d9 in QHashData::free_helper(void (*)(QHashData::Node*)) () from /usr/lib64/libQt5Core.so.5
    #4  0x00007ffff5cae07c in ?? () from /usr/lib64/libQt5Gui.so.5
    #5  0x00007fffe83febf9 in __run_exit_handlers () from /lib64/libc.so.6
    #6  0x00007fffe83fec45 in exit () from /lib64/libc.so.6
    #7  0x00007fffe83e8b0c in __libc_start_main () from /lib64/libc.so.6
    #8  0x0000000000402a26 in _start () at ../sysdeps/x86_64/start.S:122
    

    I tested this in two environments:

    • SLES 12 with Qt 5.5.0 we built ourselves
    • SLES 12 SP1 with Qt 5.5.1 from the repository

    Compiler is always GCC 4.8

    Any ideas would be appreciated.

    kshegunovK Ni.SumiN 2 Replies Last reply
    0
    • AndreasLubenskyA AndreasLubensky

      Hi,
      I'm trying to figure out a crash that occurs when I'm closing an application. The main window handles the close event and opens a QMessageBox to ask the user if he really wants to shut down.
      Now, the application crashes in the destruction of the QApplication.
      If I don't use the message box, the program shuts down nicely.

      I assembled a small test program to replicate the problem:

      #include <QMainWindow>
      #include <QApplication>
      #include <QMessageBox>
      #include <QCloseEvent>
      
      class MyMainWindow : public QMainWindow {
      protected:
        void closeEvent( QCloseEvent* e) {
          if( QMessageBox::question( this, "foo", "bar") == QMessageBox::Yes) {
            e->accept();
          } else {
            e->ignore();
          }
        }
      };
      
      int main( int argc, char** argv) {
        QApplication app( argc, argv);
      
        MyMainWindow window;
        window.show();
      
        return app.exec();
      }
      

      The call stack can differ, but this would be one example:

      #0  0x00007fffe843f195 in malloc_consolidate () from /lib64/libc.so.6
      #1  0x00007fffe843fd31 in _int_free () from /lib64/libc.so.6
      #2  0x00007ffff5cb3862 in ?? () from /usr/lib64/libQt5Gui.so.5
      #3  0x00007ffff6c336d9 in QHashData::free_helper(void (*)(QHashData::Node*)) () from /usr/lib64/libQt5Core.so.5
      #4  0x00007ffff5cae07c in ?? () from /usr/lib64/libQt5Gui.so.5
      #5  0x00007fffe83febf9 in __run_exit_handlers () from /lib64/libc.so.6
      #6  0x00007fffe83fec45 in exit () from /lib64/libc.so.6
      #7  0x00007fffe83e8b0c in __libc_start_main () from /lib64/libc.so.6
      #8  0x0000000000402a26 in _start () at ../sysdeps/x86_64/start.S:122
      

      I tested this in two environments:

      • SLES 12 with Qt 5.5.0 we built ourselves
      • SLES 12 SP1 with Qt 5.5.1 from the repository

      Compiler is always GCC 4.8

      Any ideas would be appreciated.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @AndreasLubensky
      Hello,
      Your test application works fine on my setup (Qt 5.6.1, Debian stretch Linux 4.6.0 amd64). The stack looks like some static variable's cleanup crashes, but it's not clear which or where. Try running with 5.6.1 and see if the problem is still present.

      Kind regards.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      1
      • AndreasLubenskyA AndreasLubensky

        Hi,
        I'm trying to figure out a crash that occurs when I'm closing an application. The main window handles the close event and opens a QMessageBox to ask the user if he really wants to shut down.
        Now, the application crashes in the destruction of the QApplication.
        If I don't use the message box, the program shuts down nicely.

        I assembled a small test program to replicate the problem:

        #include <QMainWindow>
        #include <QApplication>
        #include <QMessageBox>
        #include <QCloseEvent>
        
        class MyMainWindow : public QMainWindow {
        protected:
          void closeEvent( QCloseEvent* e) {
            if( QMessageBox::question( this, "foo", "bar") == QMessageBox::Yes) {
              e->accept();
            } else {
              e->ignore();
            }
          }
        };
        
        int main( int argc, char** argv) {
          QApplication app( argc, argv);
        
          MyMainWindow window;
          window.show();
        
          return app.exec();
        }
        

        The call stack can differ, but this would be one example:

        #0  0x00007fffe843f195 in malloc_consolidate () from /lib64/libc.so.6
        #1  0x00007fffe843fd31 in _int_free () from /lib64/libc.so.6
        #2  0x00007ffff5cb3862 in ?? () from /usr/lib64/libQt5Gui.so.5
        #3  0x00007ffff6c336d9 in QHashData::free_helper(void (*)(QHashData::Node*)) () from /usr/lib64/libQt5Core.so.5
        #4  0x00007ffff5cae07c in ?? () from /usr/lib64/libQt5Gui.so.5
        #5  0x00007fffe83febf9 in __run_exit_handlers () from /lib64/libc.so.6
        #6  0x00007fffe83fec45 in exit () from /lib64/libc.so.6
        #7  0x00007fffe83e8b0c in __libc_start_main () from /lib64/libc.so.6
        #8  0x0000000000402a26 in _start () at ../sysdeps/x86_64/start.S:122
        

        I tested this in two environments:

        • SLES 12 with Qt 5.5.0 we built ourselves
        • SLES 12 SP1 with Qt 5.5.1 from the repository

        Compiler is always GCC 4.8

        Any ideas would be appreciated.

        Ni.SumiN Offline
        Ni.SumiN Offline
        Ni.Sumi
        wrote on last edited by
        #3

        @AndreasLubensky

        I tested your code, It worked fine when i use Qt-kit with 5.5 with Vs2013. But it did not work well with Qt4.8.5 Vs 2008. When I use kit 4.8.5 I get yes button and its not closing at all. Both are for the same code.

        Try this code:

              virtual void closeEvent(QCloseEvent* event) {
        	   event->ignore();
        		if (QMessageBox::Yes == QMessageBox::question(this, "Close Confirmation?",
        			"Are you sure you want to exit?",
        			QMessageBox::Yes | QMessageBox::No)) {
        			event->accept();
        		}
        1 Reply Last reply
        0
        • AndreasLubenskyA Offline
          AndreasLubenskyA Offline
          AndreasLubensky
          wrote on last edited by
          #4

          I further investigated this and it seems to be related to the Qt libraries we link. Stripped down to only QtGui, QtCore, QtDBus, and QtWidgets everything works fine. In our actual environment we link many more, including both WebKit and WebEngine libraries. Might that cause some problems?

          1 Reply Last reply
          0
          • AndreasLubenskyA Offline
            AndreasLubenskyA Offline
            AndreasLubensky
            wrote on last edited by
            #5

            I figured it out, btw. We linked both libQt5QxcQpa and libQt5EglDeviceIntegration. For some reason libQt5EglDeviceIntegration has to come last, otherwise it crashes. And actually both libraries should not be explicitly linked at all.

            1 Reply Last reply
            0

            • Login

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