Bug 357577 - crashes after splash screen with ASSERT failure in QVector [patch]
Summary: crashes after splash screen with ASSERT failure in QVector [patch]
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: ProgressManager-Splashscreen (show other bugs)
Version: 5.0.0
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-05 14:16 UTC by Thomas Eschenbacher
Modified: 2022-02-05 12:59 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.0.0


Attachments
gdb backtrace (5.65 KB, text/plain)
2016-01-05 14:16 UTC, Thomas Eschenbacher
Details
console output up to the crash (9.52 KB, text/plain)
2016-01-05 14:17 UTC, Thomas Eschenbacher
Details
albummanager.patch (1.65 KB, patch)
2016-01-09 22:10 UTC, Maik Qualmann
Details
albummanager2.patch (1.93 KB, patch)
2016-01-10 11:59 UTC, Maik Qualmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Eschenbacher 2016-01-05 14:16:57 UTC
Created attachment 96472 [details]
gdb backtrace

I compiled digikam (today's latest source from git), but soon after showing the splash screen it crashes with an assertion in Qt. This also happens with a new dummy user account that did not use digikam-4 before and thus has no album, no database etc.

git commit: bb7b7ef566a1b9606f35b237ddc4b3267299209f

Gentoo Linux @ x86_64
gcc-4.8.5, qt-5.5.1

I started digikam with gdb and attached the backtrace.
Comment 1 Thomas Eschenbacher 2016-01-05 14:17:39 UTC
Created attachment 96473 [details]
console output up to the crash
Comment 2 caulier.gilles 2016-01-05 14:27:18 UTC
It sound like a Qt5 bug. 

#13 0x00000037b2808c61 in QAbstractItemModel::beginInsertRows (this=0x13c1c40, parent=..., first=0, last=0)
    at itemmodels/qabstractitemmodel.cpp:2602
#14 0x00007ffff795dc64 in Digikam::AbstractAlbumModel::slotAlbumAboutToBeAdded (this=0x13c1c40, album=0x22514a0, 
    parent=0x32a94c0, prev=0x0) at /usr/src/packages/multimedia/digikam/core/libs/models/abstractalbummodel.cpp:438

When a parent album need to be inserted in the model (prev = 0), QAbstractItemModel::beginInsertRows() i scalled with 2 arguments to 0.

I tried to reproduce the problem here, and it's not reproducible (Qt 5.5.1)

Which Qt version did you use ?

Gilles Caulier
Comment 3 Thomas Eschenbacher 2016-01-05 15:31:45 UTC
as I wrote above: Qt-5.5.1
It is 100% reproducible here.
Comment 4 Maik Qualmann 2016-01-05 19:14:57 UTC
Git commit 33d1e60c7089f5bcb862a8110cc01c82d009d42c by Maik Qualmann.
Committed on 05/01/2016 at 19:12.
Pushed by mqualmann into branch 'master'.

fix redefined signal started() in DImgThreadedFilter

M  +1    -1    libs/threads/dynamicthread.cpp
M  +1    -1    libs/threads/dynamicthread.h

http://commits.kde.org/digikam/33d1e60c7089f5bcb862a8110cc01c82d009d42c
Comment 5 Maik Qualmann 2016-01-05 19:20:57 UTC
Please try again with latest git commit. The crash is not to reproduce here.

Maik
Comment 6 Thomas Eschenbacher 2016-01-06 07:21:59 UTC
how can I get this source version you are talking about?

I followed the instructions on the project homepage, which lead me to this repo:
> git remote -v
origin  git://anongit.kde.org/digikam-software-compilation (fetch)
origin  git://anongit.kde.org/digikam-software-compilation (push)

but your change is not visible there.
I tried to "git remote set-url origin git://anongit.kde.org/digikam.git" but that has lead to a big mess, had to restore the local repo from backup.

What should I do now?
Comment 7 caulier.gilles 2016-01-07 05:46:05 UTC
The commit from Maik is located is digiKam repository, not digikam-software-compilation.

To update this code you need a recursive update. Use script in digikam-software-compilation named "gits", like this :

./gits pull 

...or go to "core" subdir where digiKam repository is and do "git pull"

Gilles Caulier
Comment 8 Thomas Eschenbacher 2016-01-07 07:57:14 UTC
thanks for the hint!

I updated the sources and recompiled the package from scratch, but still exactly the same thing happens :-(

Are you sure you have built Qt with DEBUG enabled? Otherwise the Q_ASSERT would do nothing and you would not notice that something goes wrong! (and of course you could not reproduce this)
Comment 9 Thomas Eschenbacher 2016-01-07 07:58:29 UTC
(core is now on 33d1e60c7089f5bcb862a8110cc01c82d009d42c)
Comment 10 caulier.gilles 2016-01-07 10:24:41 UTC
I just recompiled digiKam at this revision, and no crash for me in same startup conditions.

I don't know if my Qt is compiled with DEBUG flag (standard packages installed from the system).

Do you mean with debug symbols ?

Giles Caulier
Comment 11 Thomas Eschenbacher 2016-01-07 15:51:23 UTC
No, debug symbols (as you get per -g in the CFLAGS) are necessary for a usable backtrace but not sufficient.

You need to get theQt5  libs compiled "QT_DEBUG" defined and "QT_NO_DEBUG" _not_ defined, the same way you do when you want a KDE application to evaluate Q_ASSERT checks. See /usr/include/qt5/QtCore/qglobal.h  ~line 665, where Q_ASSERT is handled.

Normally Qt packages from distributions are compiled without QT_DEBUG and thus silently ignore such kinds of error situations. 

Maybe you have more luck by using a "developer build" of Qt and force digikam to use it by setting LD_LIBRARY_PATH into it. (see http://doc.qt.io/qt-5/configure-options.html and use the option "-developer-build" as suggested)
Comment 12 Maik Qualmann 2016-01-07 21:33:22 UTC
I have the code of AbstractAlbumModel::slotAlbumAboutToBeAdded(...) debugged and found nothing.

Can you digiKam with valgrind testing and post the output?

Maik
Comment 13 Thomas Eschenbacher 2016-01-09 09:29:30 UTC
sorry, that is not possible. Valgrind is broken and unusable too, crashes quite early due to this bug:
https://bugs.kde.org/show_bug.cgi?id=323431
Comment 14 caulier.gilles 2016-01-09 09:38:18 UTC
Did you use AMD based CPU on your computer ?

Gilles Caulier
Comment 15 Thomas Eschenbacher 2016-01-09 10:50:37 UTC
Yes, otherwise valgrind wouldn't complain. Anyway, I don't think valgrind could help finding this...

I now recompiled Qt with CXXFLAGS="-O0 -g -DQT_DEBUG" and got some better backtrace:

ASSERT failure in QVector<T>::at: "index out of range", file ../../include/QtCore/../../src/corelib/tools/qvector.h, line 393

Program received signal SIGABRT, Aborted.
0x000000379dc32cd7 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
55      ../sysdeps/unix/sysv/linux/raise.c: Datei oder Verzeichnis nicht gefunden.
(gdb) back
#0  0x000000379dc32cd7 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:55
#1  0x000000379dc34099 in __GI_abort () at abort.c:89
#2  0x00007ffff407ae51 in qt_message_fatal (context=..., message=...) at global/qlogging.cpp:1578
#3  0x00007ffff407734c in QMessageLogger::fatal (this=0x7fffffffc740, msg=0x7ffff438e550 "ASSERT failure in %s: \"%s\", file %s, line %d")
    at global/qlogging.cpp:781
#4  0x00007ffff4070a38 in qt_assert_x (where=0x7ffff43d6e52 "QVector<T>::at", what=0x7ffff43d6e3f "index out of range", 
    file=0x7ffff43d6e08 "../../include/QtCore/../../src/corelib/tools/qvector.h", line=393) at global/qglobal.cpp:2974
#5  0x00007ffff414d8c9 in QVector<int>::at (this=0x1391270, i=0) at ../../include/QtCore/../../src/corelib/tools/qvector.h:393
#6  0x00007ffff427921a in QSortFilterProxyModelPrivate::can_create_mapping (this=0x13912f0, source_parent=...)
    at itemmodels/qsortfilterproxymodel.cpp:416
#7  0x00007ffff427d001 in QSortFilterProxyModelPrivate::_q_sourceRowsAboutToBeInserted (this=0x13912f0, source_parent=..., start=0, end=0)
    at itemmodels/qsortfilterproxymodel.cpp:1374
#8  0x00007ffff4281555 in QSortFilterProxyModel::qt_static_metacall (_o=0x1391210, _c=QMetaObject::InvokeMetaMethod, _id=11, 
    _a=0x7fffffffca20) at .moc/moc_qsortfilterproxymodel.cpp:208
#9  0x00007ffff42f0b02 in QMetaObject::activate (sender=0x1390690, signalOffset=3, local_signal_index=9, argv=0x7fffffffca20)
    at kernel/qobject.cpp:3713
#10 0x00007ffff42f02f0 in QMetaObject::activate (sender=0x1390690, m=0x7ffff45a4ec0 <QAbstractItemModel::staticMetaObject>, 
    local_signal_index=9, argv=0x7fffffffca20) at kernel/qobject.cpp:3578
#11 0x00007ffff43873a7 in QAbstractItemModel::rowsAboutToBeInserted (this=0x1390690, _t1=..., _t2=0, _t3=0)
    at .moc/moc_qabstractitemmodel.cpp:576
#12 0x00007ffff4255569 in QAbstractItemModel::beginInsertRows (this=0x1390690, parent=..., first=0, last=0)
    at itemmodels/qabstractitemmodel.cpp:2602
#13 0x00007ffff795dc3c in Digikam::AbstractAlbumModel::slotAlbumAboutToBeAdded (this=0x1390690, album=0x21f7de0, parent=0x21f6410, prev=0x0)
    at /usr/src/packages/multimedia/digikam/core/libs/models/abstractalbummodel.cpp:438
#14 0x00007ffff7969fef in Digikam::AbstractAlbumModel::qt_static_metacall (_o=0x1390690, _c=QMetaObject::InvokeMetaMethod, _id=1, 
    _a=0x7fffffffccf0) at /usr/src/packages/multimedia/digikam/build/core/libs/models/moc_abstractalbummodel.cpp:106
#15 0x00007ffff42f0b02 in QMetaObject::activate (sender=0x7ffff7ff8b50 <_ZZN7Digikam12_GLOBAL__N_113Q_QGS_creator13innerFunctionEvE6holder>, 
    signalOffset=3, local_signal_index=0, argv=0x7fffffffccf0) at kernel/qobject.cpp:3713
---Type <return> to continue, or q <return> to quit---
#16 0x00007ffff42f02f0 in QMetaObject::activate (sender=0x7ffff7ff8b50 <_ZZN7Digikam12_GLOBAL__N_113Q_QGS_creator13innerFunctionEvE6holder>, 
    m=0x7ffff7fc6460 <Digikam::AlbumManager::staticMetaObject>, local_signal_index=0, argv=0x7fffffffccf0) at kernel/qobject.cpp:3578
#17 0x00007ffff79b2835 in Digikam::AlbumManager::signalAlbumAboutToBeAdded (
    this=0x7ffff7ff8b50 <_ZZN7Digikam12_GLOBAL__N_113Q_QGS_creator13innerFunctionEvE6holder>, _t1=0x21f7de0, _t2=0x21f6410, _t3=0x0)
    at /usr/src/packages/multimedia/digikam/build/core/libs/album/moc_albummanager.cpp:502
#18 0x00007ffff79a311b in Digikam::AlbumManager::insertPAlbum (
    this=0x7ffff7ff8b50 <_ZZN7Digikam12_GLOBAL__N_113Q_QGS_creator13innerFunctionEvE6holder>, album=0x21f7de0, parent=0x21f6410)
    at /usr/src/packages/multimedia/digikam/core/libs/album/albummanager.cpp:2899
#19 0x00007ffff799c110 in Digikam::AlbumManager::addAlbumRoot (
    this=0x7ffff7ff8b50 <_ZZN7Digikam12_GLOBAL__N_113Q_QGS_creator13innerFunctionEvE6holder>, location=...)
    at /usr/src/packages/multimedia/digikam/core/libs/album/albummanager.cpp:1224
#20 0x00007ffff799bd44 in Digikam::AlbumManager::handleCollectionStatusChange (
    this=0x7ffff7ff8b50 <_ZZN7Digikam12_GLOBAL__N_113Q_QGS_creator13innerFunctionEvE6holder>, location=..., oldStatus=0)
    at /usr/src/packages/multimedia/digikam/core/libs/album/albummanager.cpp:1179
#21 0x00007ffff799b7d9 in Digikam::AlbumManager::startScan (
    this=0x7ffff7ff8b50 <_ZZN7Digikam12_GLOBAL__N_113Q_QGS_creator13innerFunctionEvE6holder>)
    at /usr/src/packages/multimedia/digikam/core/libs/album/albummanager.cpp:1061
#22 0x00007ffff77a8a9a in Digikam::DigikamApp::DigikamApp (this=0x9193b0, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at /usr/src/packages/multimedia/digikam/core/app/main/digikamapp.cpp:251
#23 0x000000000040f829 in main (argc=1, argv=0x7fffffffd838) at /usr/src/packages/multimedia/digikam/core/app/main/main.cpp:197

(gdb) frame 5
#5  0x00007ffff414d8c9 in QVector<int>::at (this=0x1391270, i=0) at ../../include/QtCore/../../src/corelib/tools/qvector.h:393
393     { Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::at", "index out of range");
(gdb) print i
$1 = 0
(gdb) print d->size
$2 = 0

(gdb) frame 6
#6  0x00007ffff427921a in QSortFilterProxyModelPrivate::can_create_mapping (this=0x13912f0, source_parent=...)
    at itemmodels/qsortfilterproxymodel.cpp:416
416             if (gm->proxy_rows.at(source_parent.row()) == -1 ||
(gdb) list
411             if (it == source_index_mapping.constEnd()) {
412                 // Don't care, since we don't have mapping for the grand parent
413                 return false;
414             }
415             Mapping *gm = it.value();
416             if (gm->proxy_rows.at(source_parent.row()) == -1 ||
417                 gm->proxy_columns.at(source_parent.column()) == -1) {
418                 // Don't care, since parent is filtered
419                 return false;
420             }
(gdb) print gm
$3 = (QSortFilterProxyModelPrivate::Mapping *) 0x1391260
(gdb) print gm->proxy_rows
$4 = {d = 0x7ffff4391c80 <QArrayData::shared_null>}
(gdb) print source_parent
$5 = (const QModelIndex &) @0x7fffffffcb00: {r = 0, c = 0, i = 35611664, m = 0x1390690}
(gdb) print *gm
$8 = {source_rows = {d = 0x7ffff4391d78 <qt_array+24>}, source_columns = {d = 0x1393370}, proxy_rows = {
    d = 0x7ffff4391c80 <QArrayData::shared_null>}, proxy_columns = {d = 0x1393b10}, mapped_children = {
    d = 0x7ffff4391c80 <QArrayData::shared_null>}, map_iter = {i = 0x1391ff0}}

maybe that is a bit more helpful...
Comment 16 caulier.gilles 2016-01-09 11:04:27 UTC
Qt said that QVector are used out on index. This is an internal use, not from digiKam.

The Digikam::AbstractAlbumModel::slotAlbumAboutToBeAdded is called with these arguments (this=0x1390690, album=0x21f7de0, parent=0x21f6410, prev=0x0)

prev = 0 wnat mean that a parent album must be registered in model. Code relevant from digiKam is here :

https://projects.kde.org/projects/extragear/graphics/digikam/repository/revisions/master/entry/libs/models/abstractalbummodel.cpp#L422

This call Qt like this QAbstractItemModel::beginInsertRows (this=0x1390690, parent=..., first=0, last=0)

...and it crash. Note that first and last are null, which is fine with Qt API :

http://doc.qt.io/qt-5/qabstractitemmodel.html#beginInsertRows

Gilles Caulier
Comment 17 Maik Qualmann 2016-01-09 22:10:36 UTC
Created attachment 96548 [details]
albummanager.patch

Can you try this patch in the "core" subdirectory?

patch -p0 < albummanager.patch

Maik
Comment 18 Maik Qualmann 2016-01-10 11:59:36 UTC
Created attachment 96562 [details]
albummanager2.patch

A trash for each root album working again.

Maik
Comment 19 Thomas Eschenbacher 2016-01-10 22:39:30 UTC
Thanks for the patch! 

It does not show any of my albums and I cannot see any picture anywhere,  so the application is pretty useless at the moment, but at least it starts and no longer crashes! :-)

The "Album" tree view (or whatever that widget on the left side is), is nearly empty, it contains only the string "Albums" with something that looks like a generic "image" icon at the left. Nothing else, nothing to expand or collapse...

Another odd thing: it seems that the settings have not been properly migrated, the strings to my albums were URL encoded or so, the edit fields showed strings like "%2Fhome%2Fuser%2FPictures". After I added my local collection manually again, I can see in the console debug output that it iterates over my complete collection and tries to do some face detection. But still nothing in the Albums list.

BTW: Additionally face detection seems to have problems with special characters (unicode) in file names, it shows "file system" errors or file "format not recognized" error for these files, maybe something with file name encoding or conversion QFile-name <-> QUrl goes wrong (I also had these things in Kwave).
Comment 20 Thomas Eschenbacher 2016-01-10 22:47:12 UTC
short update: now, after waiting for a very very long time, it shows Albums and Images again! It seems that it had to do it's job about face recognition in background, without any visible hint for the user what is going on. It was just luck that I recognized this, because I started it from the console, normally I would have given up already, called the "useless" and killed it.
Comment 21 Maik Qualmann 2016-01-11 19:31:54 UTC
Git commit e10a52aefc55d6e47e736910353a53546fd21fde by Maik Qualmann.
Committed on 11/01/2016 at 19:29.
Pushed by mqualmann into branch 'master'.

insert trash album after root album, otherwise not exist the parent album
FIXED-IN: 5.0.0

M  +2    -1    NEWS
M  +9    -4    libs/album/albummanager.cpp

http://commits.kde.org/digikam/e10a52aefc55d6e47e736910353a53546fd21fde
Comment 22 caulier.gilles 2016-01-12 07:44:04 UTC
To Thomas, from comment #19 :

>BTW: Additionally face detection seems to have problems with special characters (unicode) in file >names, it shows "file system" errors or file "format not recognized" error for these files, maybe >something with file name encoding or conversion QFile-name <-> QUrl goes wrong (I also had >these things in Kwave).

Can you open a new file in bugzilla about this problem with :

1/ The file name pattern to use to reproduce the problem
2/ The console backtrace while the problem appears.

Note : KUrl to QUrl port was been a big mess and need huge regression tests. Typically, in the future, we will take a care to use less KDE API when Qt API do the job as well. It's typically a waste of time to port back from KDE to Qt and can introduce undesired dysfunctions in code. Porting KUrl to QUrl take me more than one month for only digiKam core , which is unacceptable for a project as digiKam...

Gilles Caulier