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.