[Interest] Weird assert, how to debug?

Axel Spoerl axel.spoerl at qt.io
Sat Mar 4 12:47:39 CET 2023


Hi Scott,
the assertion doesn't fire on Qt 5.15.8, 6.4, 6.5, 6.6 / Linux XCB.
Neither from any debugger, nor from the cmd line. Release build doesn't crash either.
Before it eventually builds, the reproducer rightfully rants about a missing ../TestFocusAssert-trunk/MainWindow.qrc
Maybe the issue is triggered by / results from its content.
=> You could try moving that file in and out.
=> If the issue persists, please file a bug at https://bugreports.qt.io and include a complete reproducer.
Brgds
Axel
________________________________
Von: Scott Bloom <scott at towel42.com>
Gesendet: Freitag, 3. März 2023 19:42
An: Axel Spoerl <axel.spoerl at qt.io>; interest at qt-project.org <interest at qt-project.org>
Betreff: RE: Weird assert, how to debug?


Qt Creator? Never heard of it 😊  I use Visual Studio, but I did already try this.



The assert kicks off directly from the command line as well.



Scott



From: Interest <interest-bounces at qt-project.org> On Behalf Of Axel Spoerl via Interest
Sent: Friday, March 3, 2023 9:43 AM
To: interest at qt-project.org
Subject: Re: [Interest] Weird assert, how to debug?



Hi Scot,

Please try running the executable from outside Qt Creator to eliminate its debugger as the troublemaker.

Cheers

Axel



On 3 Mar 2023, at 18:33, Scott Bloom <scott at towel42.com<mailto:scott at towel42.com>> wrote:



As you can see by the sample, Im not doing anything special, not changing any ownership, and not doing any individual deletes + deleteLaters with a processEvents (The root cause of many a “double delete in my experience”), so Im really stumped on this one.



Something in designer with the UI file is causing this.

Scott



From: Interest <interest-bounces at qt-project.org<mailto:interest-bounces at qt-project.org>> On Behalf Of Axel Spoerl via Interest
Sent: Thursday, March 2, 2023 10:09 PM
To: interest at qt-project.org<mailto:interest at qt-project.org>
Subject: Re: [Interest] Weird assert, how to debug?



Hi Scott,



I can't make the reproducer crash on Qt 5.15.9 or on the latest dev (6.6).

The assertion happens in QWidget's destructor, when it wants to exit from the focus list.

I can imagine two cases, how this assertion kicks in.

  1.  The code path in the if statement right after the assertion has been reached before:
if (d->focus_next != this) {
        d->focus_next->d_func()->focus_prev = d->focus_prev;
        d->focus_prev->d_func()->focus_next = d->focus_next;
        d->focus_next = d->focus_prev = nullptr;
}

=> An already deleted widget is deleted a second time.

  1.  Focus chain has changed without events having been processed, so the destroyed widget doesn't know about it.
Happens in the debugger (e.g. Qt Creator) sometimes, because debugging output is a notirious focus thief.

Option 2 seems more likely to me, since the assertion doesn't shout in release builds.

Updating to the latest Qt Creator version may help. If it doesn't please file a bugreport in https://bugreports.qt.io,

upload the reproducer, specify the Qt and (Qt Creator if used for debugging) versions used.



Cheers
Axel

________________________________

Von: Interest <interest-bounces at qt-project.org<mailto:interest-bounces at qt-project.org>> im Auftrag von Scott Bloom <scott at towel42.com<mailto:scott at towel42.com>>
Gesendet: Freitag, 3. März 2023 01:37
An: interest at qt-project.org<mailto:interest at qt-project.org> <interest at qt-project.org<mailto:interest at qt-project.org>>
Betreff: [Interest] Weird assert, how to debug?



Im getting an assertion in qwidget.cpp

“d->focus_prev->d_func()->focus_next == this” in Qwidget.cpp line 1443 (Qt 5.15.10)



I realize the response is going to be, create a minimal example, I created a repo on github with it, it’s a simple cmake based project. Any help figuring this out would be appreciated.



The application has a QApplication and a QDialog derived dialog.  The dialog has a tabwidget and a dialogbutton box.

The assertion gets thrown when the dialog is destroyed.



https://github.com/towel42-com/TestFocusAssert



This happens on Windows, I don’t have a linux box setup right now to test on linux.



Thanks

Scott








-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230304/987df67b/attachment.htm>


More information about the Interest mailing list