> > I did get rid of the segfault by removing: serPort->deleteLater();
> > from my MainWindow destructor.
>
> Ok, that's expected, as this avoids the second deletion.
So the only thing I can see that is related between my serial port object
(since getting rid of the serPort->deleteLater() call seems to fix things) and
a QAction object is that I've got some QAction signals connected to slots in
that serial port object. So does that make sense that the backtrace might show
an issue in the QAction destructor? I'm guessing maybe that as the QAction is
getting destroyed, it's trying to disconnect all of its signals, but because
the serial port object is already gone, it's causing a problem? Otherwise, I'm
a little stumped since I never explicitly delete any of the QAction objects, I
just let the QObject parent/child system take care of this.
I originally had put the deleteLater() call in my destructor because in my
constructor I had:
serialPortThread = new QThread(this);
serPort = new ECMSerialPort(); // <- unparented since otherwise
moveToThread() fails
serPort->moveToThread(serialPortThread);
serialPortThread->start();
So I assumed that serPort was unparented at this point, and I would need to
explicitly delete it at some point? Does moveToThread() reparent the object
from null to become a child of the QThread object? Otherwise it seems like I'm
leaving that object behind when the application quits.
> Is your code accessible somewhere?
Unfortunately, no. It's proprietary code, so I can't put all of it up on
github. I can try to include snippets if you need to see them, but there's
probably parts I would have to edit out, so at some point what I post there
will be different enough that it might not be a good representation of the
actual code.
> > But I think my real question right now is, how can I use QtCreator's
> > debugging setup to help track this down?
>
> What's easiest/quickest depends a bit on your exact setup.
>
> If your application can be compiled on Linux, then the quickest would be to
> run it under valgrind, either from the command line or within Creator by
> using Analyze->Valgrind Analyzer. The result would directly point you to both
> deallocations (something like "Invalid free at <address2> file2.cpp:123,
> address is inside a free'd block at <address1> file1.cpp:456")
I haven't tried to compile it under Linux. In theory, I'm not doing anything
that should be platform specific, so I think this might be possible. I'll see
if I have time to make this happen.
> Otherwise, you could try to set a breakpoint on the QAction::~QAction()
> destructor. If that works (might not, depending on you Qt build), repeated
> <F5> gives you one the destruction of one QAction per iteration, if the
> application is not overly big, spotting a duplicate "manually" might be
> possible.
When I run the application in debug mode in QtCreator, and just let it break on
its own, I get the following stack dump. In this dump, only lines 26 & 27 are
black, all the other lines are greyed out and I can't step into them. So I'm
guessing that means I'm running with a release version of Qt, not debug? If
that's the case, what would I need to do to make QtCreator use the debug
versions of Qt? I used this installer to get Qt,
qt-windows-opensource-5.2.0-mingw48_opengl-x86-offline.exe, so maybe I don't
even have the source code? A quick search on my machine doesn't find a
qaction.cpp file anywhere, so that might explain why I can't step into that
code!
0 ntdll!TpWaitForAlpcCompletion C:\windows\system32\ntdll.dll
0x77410575
1 ?? 0x28f7d8
2 ntdll!AlpcMaxAllowedMessageLength C:\windows\system32\ntdll.dll
0x773ca412
3 ?? 0x157d3e68
4 ntdll!RtlReleasePebLock C:\windows\system32\ntdll.dll
0x773735b7
5 ?? 0x9
6 ?? 0x8
7 ?? 0x28f8a0
8 ntdll!LdrLoadAlternateResourceModuleEx C:\windows\system32\ntdll.dll
0x773734a2
9 ?? 0x157d3eb0
10 ntdll!RtlValidateHeap C:\windows\system32\ntdll.dll
0x7741172e
11 ?? 0x13fb0000
12 ntdll!AlpcMaxAllowedMessageLength C:\windows\system32\ntdll.dll
0x773cac29
13 ?? 0x13fb0000
14 ntdll!LdrLoadAlternateResourceModuleEx C:\windows\system32\ntdll.dll
0x773734a2
15 ?? 0x157d3eb0
16 msvcrt!free C:\windows\syswow64\msvcrt.dll 0x75e798cd
17 ?? 0x13fb0000
18 QWidgetAction::~QWidgetAction qwidgetaction.cpp 130
0xa8b54a8
19 QObjectPrivate::deleteChildren qobject.cpp 1835 0x6b941c3f
20 QWidget::~QWidget qwidget.cpp 1486 0xa89ec02
21 QToolBar::~QToolBar qtoolbar.cpp 570 0xaa1b1ab
22 QToolBar::~QToolBar qtoolbar.cpp 582 0xaa1b1d9
23 QObjectPrivate::deleteChildren qobject.cpp 1835 0x6b941c3f
24 QWidget::~QWidget qwidget.cpp 1486 0xa89ec02
25 QMainWindow::~QMainWindow qmainwindow.cpp 378 0xa9c47fe
26 MainWindow::~MainWindow mainwindow.cpp 249 0x404f16
27 qMain main.cpp 8 0x40168e
28 WinMain@16 qtmain_win.cpp 131 0x43a2fd
29 main 0x469a5d
Thanks,
Sean
_______________________________________________
Qt-creator mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/qt-creator