Results 1 to 2 of 2

Thread: Debugging issues -debugger stuck?

  1. #1
    Join Date
    Jun 2014
    Posts
    10
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Debugging issues -debugger stuck?

    Hey everyone, I've recently been poking around migrating and adding features to an old project using Qt 5.14.1,
    This time I'm more than sure that I introduced a memory corruption bug (due to the line where it consistently fails) but upon calling the debugger it gets stuck.

    At first, launching it gets it stopped at RtlUserThreadStart, and on thread #4, however when I try to continue cdb, it launches another thread (stoping at the same place).
    This keeps on going until it reaches thread number 7, when "Run requested" is seen in the status bar, and I can no longer press the continue running button.

    The bottom right status message from QtCreator keeps on at 25% saying "Launching debugger".

    The code where it fails leads me to think there is memory corruption do to it being:

    Qt Code:
    1. //WidgetRenglonComprobante is a QWidget derived class who has the Q_OBJECT macro
    2. QVector<WidgetRenglonComprobante*> renglones;
    3. // (...)
    4. for (auto &r : renglones)
    5. {
    6. //adding some error checking here and changing the for to an index oriented one, I get to see the same behaviour, at first I thought the item was out of bounds
    7. //but that shouldn't be possible this way, and accessing the item (making a reference to it like qDebug()-ing it to see if it was null/nullptr also makes it crash
    8. r->calculateTotal();
    9. }
    To copy to clipboard, switch view to plain text mode 

    The bug is triggered whenever I remove one of the dynamically created widgets which are contained in a VBoxLayout (and the VBoxLayout is created with a scrollAreaWidgetContents parent), each widget has a 'remove button', which upon emitted, the parent (who holds the vbox and the scrollareawidget and scrollareawidgetcontents objects) catches and does:

    Qt Code:
    1. WidgetRenglonComprobante * renglon = static_cast<WidgetRenglonComprobante*>(sender());
    2. qDebug() << "renglon = " << renglon;
    3. if (renglonActual == renglon)
    4. renglonActual = nullptr;
    5. renglones.remove(contenedorRenglones->indexOf(renglon)); // contenedorRenglones is a VBoxLayout
    6. contenedorRenglones->removeWidget(renglon);
    7. renglon->deleteLater();
    8. qDebug() << "renglones.size()" << renglones.size();
    To copy to clipboard, switch view to plain text mode 

    The widget is removed from view correctly, however aparently renglones has some issue (QVector) and upon trying to access the remaining ones upon saving the data is where the bug is triggered -size() shows after the elimination that its been removed-.
    What can I do to fix the debugger stopping? In the meantime I'll try to audit the code and look for anything I've dynamically allocated to see if I can find the issue.

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    519
    Thanks
    13
    Thanked 77 Times in 75 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Debugging issues -debugger stuck?

    Hi, this is just a guess, and I'm not even sure if this applies to QVector: in std::vector, when you erase an element, you invalidate all iterators pointing to the following elements. Maybe your "for (auto &r : renglones)" loop has some similar problems?

    Ginsengelf

Similar Threads

  1. Replies: 1
    Last Post: 19th January 2013, 05:08
  2. Problem with remote debugging and issues in building for ARM target
    By badri89 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 14th October 2012, 08:47
  3. Debugger: None of the debugger engines [...] capable of debugging binaries
    By schludy in forum Installation and Deployment
    Replies: 1
    Last Post: 21st February 2012, 18:32
  4. Debugging issues
    By Plissken in forum Newbie
    Replies: 0
    Last Post: 17th January 2011, 02:51
  5. Replies: 3
    Last Post: 6th September 2010, 23:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.