Segfault with Qt-5.11.0

2018-05-23 Thread Gaetan Bisson
Dear all,

I'm getting a segfault when running Subsurface with Qt-5.11. It occurs
with both an old binary compiled against Qt-5.10 and a freshly rebuilt
binary. Note that building against Qt-5.11 requires fixing a couple of
headers, but that's unrelated:

https://github.com/Subsurface-divelog/subsurface/pull/1317

The segfault occurs whenever the dive list is nonempty. With a new
profile, just click on "Log" then "Add Dive" and then "Apply Changes" to
trigger it. Here's a backtrace:


Thread 1 "subsurface" received signal SIGSEGV, Segmentation fault.
0x705aa4d2 in QSortFilterProxyModel::parent(QModelIndex const&) const 
() from /usr/lib/libQt5Core.so.5
(gdb) bt
#0  0x705aa4d2 in QSortFilterProxyModel::parent(QModelIndex const&) 
const () at /usr/lib/libQt5Core.so.5
#1  0x7291f60a in QTreeView::drawRow(QPainter*, QStyleOptionViewItem 
const&, QModelIndex const&) const () at /usr/lib/libQt5Widgets.so.5
#2  0x72924e7f in QTreeView::drawTree(QPainter*, QRegion const&) const 
() at /usr/lib/libQt5Widgets.so.5
#3  0x729299f8 in QTreeView::paintEvent(QPaintEvent*) () at 
/usr/lib/libQt5Widgets.so.5
#4  0x726a0058 in QWidget::event(QEvent*) () at 
/usr/lib/libQt5Widgets.so.5
#5  0x727467df in QFrame::event(QEvent*) () at 
/usr/lib/libQt5Widgets.so.5
#6  0x728c0b84 in QAbstractItemView::viewportEvent(QEvent*) () at 
/usr/lib/libQt5Widgets.so.5
#7  0x7292aa3c in QTreeView::viewportEvent(QEvent*) () at 
/usr/lib/libQt5Widgets.so.5
#8  0x705cf8db in 
QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () at 
/usr/lib/libQt5Core.so.5
#9  0x72660974 in QApplicationPrivate::notify_helper(QObject*, QEvent*) 
() at /usr/lib/libQt5Widgets.so.5
#10 0x7266825b in QApplication::notify(QObject*, QEvent*) () at 
/usr/lib/libQt5Widgets.so.5
#11 0x705cfbc9 in QCoreApplication::notifyInternal2(QObject*, QEvent*) 
() at /usr/lib/libQt5Core.so.5
#12 0x726989bc in QWidgetPrivate::sendPaintEvent(QRegion const&) () at 
/usr/lib/libQt5Widgets.so.5
#13 0x72699141 in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion 
const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
at /usr/lib/libQt5Widgets.so.5
#14 0x72699e2e in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, 
QList const&, int, QRegion const&, QPoint const&, int, QPainter*, 
QWidgetBackingStore*) () at /usr/lib/libQt5Widgets.so.5
#15 0x72699d14 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, 
QList const&, int, QRegion const&, QPoint const&, int, QPainter*, 
QWidgetBackingStore*) () at /usr/lib/libQt5Widgets.so.5
#16 0x72699d14 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, 
QList const&, int, QRegion const&, QPoint const&, int, QPainter*, 
QWidgetBackingStore*) () at /usr/lib/libQt5Widgets.so.5
#17 0x72699d14 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, 
QList const&, int, QRegion const&, QPoint const&, int, QPainter*, 
QWidgetBackingStore*) () at /usr/lib/libQt5Widgets.so.5
#18 0x72698f0d in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion 
const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
at /usr/lib/libQt5Widgets.so.5
#19 0x72699e2e in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, 
QList const&, int, QRegion const&, QPoint const&, int, QPainter*, 
QWidgetBackingStore*) () at /usr/lib/libQt5Widgets.so.5
#20 0x72698f0d in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion 
const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
at /usr/lib/libQt5Widgets.so.5
#21 0x72699e2e in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, 
QList const&, int, QRegion const&, QPoint const&, int, QPainter*, 
QWidgetBackingStore*) () at /usr/lib/libQt5Widgets.so.5
#22 0x72698f0d in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion 
const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
at /usr/lib/libQt5Widgets.so.5
#23 0x72699e2e in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, 
QList const&, int, QRegion const&, QPoint const&, int, QPainter*, 
QWidgetBackingStore*) () at /usr/lib/libQt5Widgets.so.5
#24 0x72699d14 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, 
QList const&, int, QRegion const&, QPoint const&, int, QPainter*, 
QWidgetBackingStore*) () at /usr/lib/libQt5Widgets.so.5
#25 0x72699d14 in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, 
QList const&, int, QRegion const&, QPoint const&, int, QPainter*, 
QWidgetBackingStore*) () at /usr/lib/libQt5Widgets.so.5
#26 0x72698f0d in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion 
const&, QPoint const&, int, QPainter*, QWidgetBackingStore*) ()
at /usr/lib/libQt5Widgets.so.5
#27 0x72699e2e in QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, 
QList const&, int, QRegion const&, QPoint const&, int, QPainter*, 
QWidgetBackingStore*) () at /usr/lib/libQt5

Re: Segfault with Qt-5.11.0

2018-05-23 Thread Thiago Macieira
On Wednesday, 23 May 2018 05:08:58 -03 Gaetan Bisson wrote:
> Any ideas how to debug this?

Can you valgrind? Without debug symbols in Qt it may be a little difficult to 
make sense of what we're seeing, but it might help.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center



___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: Segfault with Qt-5.11.0

2018-05-23 Thread Gaetan Bisson
[2018-05-23 07:12:45 -1000] Gaetan Bisson:
> [2018-05-23 10:28:52 -0300] Thiago Macieira:
> > On Wednesday, 23 May 2018 05:08:58 -03 Gaetan Bisson wrote:
> > > Any ideas how to debug this?
> > 
> > Can you valgrind? Without debug symbols in Qt it may be a little difficult 
> > to 
> > make sense of what we're seeing, but it might help.
> 
> Sure; see valgrind's log attached. The core dump is too big to send by
> email but I can find a way to get it to you if needed. Also, while I was
> asleep, Arch's Qt packager bisected the faulty commit to:
> 
>   
> http://code.qt.io/cgit/qt/qtbase.git/patch/?id=1c0fcbc887459d8963088309e83303eb1a7d2db0
>   
> Which I note is also suspected for other segfaults:
> 
>   https://github.com/lxqt/libfm-qt/issues/164
> 
> He has reported this issue there:
> 
>   https://bugreports.qt.io/browse/QTBUG-68427

Oh, it's also there:

https://bugreports.qt.io/browse/QTBUG-67948

Cheers.

-- 
Gaetan
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: Segfault with Qt-5.11.0

2018-05-24 Thread Gaetan Bisson
[2018-05-23 07:20:43 -1000] Gaetan Bisson:
> Oh, it's also there:
> 
>   https://bugreports.qt.io/browse/QTBUG-67948

It turns out removing oldModel->deleteLater(); from DiveListView::reload()
avoids the segfault. See the discussion in the above bug report. However I
have no idea what the proper fix should be.

Cheers.

-- 
Gaetan
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: Segfault with Qt-5.11.0

2018-05-24 Thread Berthold Stoeger
On Donnerstag, 24. Mai 2018 22:46:30 CEST Gaetan Bisson wrote:
> [2018-05-23 07:20:43 -1000] Gaetan Bisson:
> > Oh, it's also there:
> > https://bugreports.qt.io/browse/QTBUG-67948
> 
> It turns out removing oldModel->deleteLater(); from DiveListView::reload()
> avoids the segfault. See the discussion in the above bug report. However I
> have no idea what the proper fix should be.

For one, we could delete it directly, c.f. attached patch. Probably it will 
still crash (no recent Qt to test, sorry), but at least we might get a useful 
back trace. deleteLater() is evil.

Berthold
>From 479eccd89ae138ecab5bf6513d5ee5051137797e Mon Sep 17 00:00:00 2001
From: Berthold Stoeger 
Date: Thu, 24 May 2018 22:57:02 +0200
Subject: [PATCH] Cleanup: Don't defer deletion of oldModel in
 DiveListView::reload()

There seems to be no point in using deleteLater() of the previous
model. Set the new model and delete the old one.

Signed-off-by: Berthold Stoeger 
---
 desktop-widgets/divelistview.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp
index 659d8e842..999edd39c 100644
--- a/desktop-widgets/divelistview.cpp
+++ b/desktop-widgets/divelistview.cpp
@@ -425,13 +425,12 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort)
 
 	QSortFilterProxyModel *m = qobject_cast(model());
 	QAbstractItemModel *oldModel = m->sourceModel();
-	if (oldModel) {
-		oldModel->deleteLater();
-	}
 	tripModel = new DiveTripModel(this);
 	tripModel->setLayout(layout);
 
 	m->setSourceModel(tripModel);
+	if (oldModel)
+		delete oldModel;
 
 	if (!forceSort)
 		return;
-- 
2.14.1

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: Segfault with Qt-5.11.0

2018-05-24 Thread Gaetan Bisson
[2018-05-24 23:04:28 +0200] Berthold Stoeger:
> On Donnerstag, 24. Mai 2018 22:46:30 CEST Gaetan Bisson wrote:
> > [2018-05-23 07:20:43 -1000] Gaetan Bisson:
> > > Oh, it's also there:
> > >   https://bugreports.qt.io/browse/QTBUG-67948
> > 
> > It turns out removing oldModel->deleteLater(); from DiveListView::reload()
> > avoids the segfault. See the discussion in the above bug report. However I
> > have no idea what the proper fix should be.
> 
> For one, we could delete it directly, c.f. attached patch.

There's no segfault with that patch.

Weird but good. :)

-- 
Gaetan
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface