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. Error when exiting program with qDebug() output

Error when exiting program with qDebug() output

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 451 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.
  • A Offline
    A Offline
    anthel
    wrote on last edited by
    #1

    Greetings:

    I have an OpenGL Qt application and when I launch it from the command line and pass it the --verbose argument to turn on output from qDebug(), I get errors when I exit the application. If that flag is not passed and, therefore, qDebug() is not called, the application exits successfully. How can I gracefully exit? Thank you for your help with this; it is much appreciated.

    Error:

    Foo(36726,0x7fffa465a380) malloc: *** error for object 0x7f876e49fad0: pointer being freed was not allocated
    *** set a breakpoint in malloc_error_break to debug
    Abort trap: 6
    

    Application Information:

    • On macOS, I launch the application on the terminal to get the output by doing the following: ./Foo.app/Contents/MacOS/Foo --verbose
    • Code and object creation is similar to "Hello GL2 Example" at Hello GL2 Example

    System Information:

    • macOS 10.13.6
    • issue occurs with Qt versions 5.11.2, 5.11.3, and 5.12.0

    Kind regards,
    Anthel

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Looks like one of the objects is getting deleted through parent and object is not dynamically created. Just check your code.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • A Offline
        A Offline
        anthel
        wrote on last edited by anthel
        #3

        Greetings:

        I believe @dheerendra is correct and that I was ultimately bit by the compiler. My GLWidget::cleanup() is called twice. When I put some printf() statements throughout this function the error went away. So, when I leave one within my if (m_program == nullptr) block, I suddenly do not get the error. Is there a common pragma or something else I can do to this evaluation besides the printf() to force the compiler to not get cute in this portion of the code? Thank you for the very prompt response on this and this forum's help!

        void GLWidget::cleanup()
        {
            if (m_program == nullptr)
            {
                printf("INFO:GLWidget:cleanup: Successfully exited OpenGL Widget\n");
                return;
            }
            makeCurrent();
            m_entitySurfVbo.destroy();
            m_entityAxesVbo.destroy();
            m_entityPtsVbo.destroy();
            delete m_program;
            m_program = NULL;
            doneCurrent();
        }
        

        My compiler information is below.

        $ g++ --version
        g++ (MacPorts gcc8 8.2.0_3) 8.2.0
        Copyright (C) 2018 Free Software Foundation, Inc.
        This is free software; see the source for copying conditions.  There is NO
        warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
        

        Kind regards,
        Anthel

        1 Reply Last reply
        0
        • A Offline
          A Offline
          anthel
          wrote on last edited by
          #4

          Greetings:

          I ended up just putting a single ; instead of the printf() and now things work as expected. I cannot figure out a better cross-compiler way of addressing this. If someone else does, then please post. Again, thank you for your help with this.

          Kind regards,
          Anthel

          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