Bug 461651 - digiKam segfault immediately after "Scan collection for faces"
Summary: digiKam segfault immediately after "Scan collection for faces"
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Faces-Workflow (other bugs)
Version First Reported In: 7.8.0
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2022-11-10 03:54 UTC by James Beddek
Modified: 2023-03-06 21:36 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 8.0.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Beddek 2022-11-10 03:54:03 UTC
Application: digikam (7.8.0)
 (Compiled from sources)
Qt Version: 5.15.5
Frameworks Version: 5.99.0
Operating System: Linux 6.0.7-gentoo x86_64
Windowing System: X11
Distribution: "Gentoo Linux"
DrKonqi: 5.26.2 [KCrashBackend]

-- Information about the crash:
The program crashed after clicking on "Scan collection for faces". The settings used were face detection (not recognition), "YOLOv3", and "all processor cores".
I haven't seen this crash before, and cannot replicate it again.

The crash does not seem to be reproducible.

-- Backtrace:
Application: digiKam (digikam), signal: Segmentation fault
Content of s_kcrashErrorMessage: std::unique_ptr<char []> = {get() = 0x0}
[KCrash Handler]
#5  std::__atomic_base<int>::load(std::memory_order) const (this=0x0, __m=std::memory_order_relaxed) at /usr/lib/gcc/x86_64-pc-linux-gnu/11.3.0/include/g++-v11/bits/atomic_base.h:481
#6  QAtomicOps<int>::loadRelaxed<int>(std::atomic<int> const&) (_q_value=<error reading variable: Cannot access memory at address 0x0>) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/include/QtCore/../../src/corelib/thread/qatomic_cxx11.h:239
#7  QBasicAtomicInteger<int>::loadRelaxed() const (this=0x0) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/include/QtCore/../../src/corelib/thread/qbasicatomic.h:107
#8  QtPrivate::RefCount::deref() (this=0x0) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/include/QtCore/../../src/corelib/tools/qrefcount.h:66
#9  QString::operator=(QString const&) (this=0x563378e995f0, other=...) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/src/corelib/text/qstring.cpp:2404
#10 0x00007f7306155244 in Digikam::ItemInfo::ItemInfo(Digikam::ItemListerRecord const&) (this=0x7ffda3df1a20, record=...) at /usr/src/debug/media-gfx/digikam-7.8.0-r1/digikam-7.8.0/core/libs/database/item/containers/iteminfo.cpp:51
#11 0x00007f73069632f8 in Digikam::ItemInfoJob::slotData(QList<Digikam::ItemListerRecord> const&) (this=0x563371351a20, records=<optimized out>) at /usr/src/debug/media-gfx/digikam-7.8.0-r1/digikam-7.8.0/core/utilities/maintenance/iteminfojob.cpp:177
#12 0x00007f730696105a in Digikam::ItemInfoJob::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=0x0, _c=<optimized out>, _id=1, _a=0x3) at core/utilities/maintenance/gui_maintenance_obj_autogen/EWIEGA46WW/moc_iteminfojob.cpp:96
#13 0x00007f73042de775 in doActivate<false>(QObject*, int, void**) (sender=0x5633715fb770, signal_index=6, argv=0x7ffda3df1b90) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/src/corelib/kernel/qobject.cpp:3898
#14 0x00007f73060bd5a1 in Digikam::DBJobsThread::data(QList<Digikam::ItemListerRecord> const&) (this=0x0, _t1=...) at core/libs/database/digikamdatabase_obj_autogen/HQ6CMPHILZ/moc_dbjobsthread.cpp:162
#15 Digikam::DBJobsThread::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=0x0, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at core/libs/database/digikamdatabase_obj_autogen/HQ6CMPHILZ/moc_dbjobsthread.cpp:89
#16 0x00007f73042d4e5e in QObject::event(QEvent*) (this=0x5633715fb770, e=0x7f712c124500) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/src/corelib/kernel/qobject.cpp:1314
#17 0x00007f7304ec2c91 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=0x5633593d33c0, receiver=0x5633715fb770, e=0x7f712c124500) at /usr/src/debug/dev-qt/qtwidgets-5.15.5-r1/qtbase-everywhere-src-5.15.5/src/widgets/kernel/qapplication.cpp:3637
#18 0x00007f7304ec4302 in QApplication::notify(QObject*, QEvent*) (this=0x7ffda3df23b8, receiver=0x5633715fb770, e=0x7f712c124500) at /usr/src/debug/dev-qt/qtwidgets-5.15.5-r1/qtbase-everywhere-src-5.15.5/src/widgets/kernel/qapplication.cpp:2976
#19 0x00007f73042a65de in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x5633715fb770, event=0x7f712c124500) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/src/corelib/kernel/qcoreapplication.cpp:1064
#20 0x00007f73042a7c87 in QCoreApplication::sendEvent(QObject*, QEvent*) (receiver=0x5633715fb770, event=0x7f712c124500) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/src/corelib/kernel/qcoreapplication.cpp:1462
#21 QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (receiver=0x0, event_type=0, data=0x5633595016a0) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/src/corelib/kernel/qcoreapplication.cpp:1821
#22 0x00007f7304306250 in QCoreApplication::sendPostedEvents(QObject*, int) (receiver=0x0, event_type=0) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/src/corelib/kernel/qcoreapplication.cpp:1680
#23 postEventSourceDispatch(_GSource*, int (*)(void*), void*) (s=0x5633596e4420) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/src/corelib/kernel/qeventdispatcher_glib.cpp:277
#24 0x00007f72f7374be5 in g_main_dispatch (context=0x7f72b0005010) at ../glib-2.74.1/glib/gmain.c:3444
#25 g_main_context_dispatch (context=0x7f72b0005010) at ../glib-2.74.1/glib/gmain.c:4162
#26 0x00007f72f73750db in g_main_context_iterate (context=0x7f72b0005010, block=1, dispatch=1, self=<optimized out>) at ../glib-2.74.1/glib/gmain.c:4238
#27 0x00007f72f737529c in g_main_context_iteration (context=0x7f72b0005010, may_block=1) at ../glib-2.74.1/glib/gmain.c:4303
#28 0x00007f73043058a2 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x5633597196d0, flags=...) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/src/corelib/kernel/qeventdispatcher_glib.cpp:423
#29 0x00007f73042a2197 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x7ffda3df21b8, flags=...) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/src/corelib/kernel/qeventloop.cpp:139
#30 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x7ffda3df21b8, flags=...) at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/src/corelib/kernel/qeventloop.cpp:232
#31 0x00007f73042a6cb1 in QCoreApplication::exec() () at /usr/src/debug/dev-qt/qtcore-5.15.5-r3/qtbase-everywhere-src-5.15.5/src/corelib/kernel/qcoreapplication.cpp:1375
#32 0x0000563358edc93c in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/media-gfx/digikam-7.8.0-r1/digikam-7.8.0/core/app/main/main.cpp:418
[Inferior 1 (process 3453) detached]

Reported using DrKonqi
Comment 1 Maik Qualmann 2022-11-10 07:06:52 UTC
The crash occurs relatively deep in Qt. In ItemInfo we copy a QString, this operation is executed inside a write lock. I suspect the reason for the crash to be somewhere else. Please try to create a full backtrace with GDB.

Did you download the face engine data completely and then restart digiKam before you tried the face detection?

Maik
Comment 2 caulier.gilles 2022-11-10 07:46:50 UTC
Also, can your reproduce the dysfunction using 7.9.0 pre-release Linux AppImage bundle available here :

https://files.kde.org/digikam/

Gilles Caulier
Comment 3 James Beddek 2022-11-10 08:22:32 UTC
Hi, thanks for the very prompt response.

(In reply to Maik Qualmann from comment #1)
> The crash occurs relatively deep in Qt. In ItemInfo we copy a QString, this
> operation is executed inside a write lock. I suspect the reason for the
> crash to be somewhere else. Please try to create a full backtrace with GDB.
> 
> Did you download the face engine data completely and then restart digiKam
> before you tried the face detection?
> 

No, this is purely a one-off segfault. I've used it multiple times before without issues.

> Maik

(In reply to caulier.gilles from comment #2)
> Also, can your reproduce the dysfunction using 7.9.0 pre-release Linux
> AppImage bundle available here :
> 
> https://files.kde.org/digikam/
> 
> Gilles Caulier

So it appears I can replicate the crash ~1/5 of time purely by starting the scan.
I've tested 'digiKam-7.9.0-20221108T161738-x86-64-debug.appimage' and crash with that too.

Here is the backtrace from the original crash:
https://dpaste.com/3KTU68S5K

Here is the backtrace from the debug appimage:
https://dpaste.com/2NM8LNUFL

It doesn't look like the debug appimage has symbols for Qt.
I'll also add that the appimage depends on /usr/lib64/libpcre.so.3 which appears to be a debian (?) specific soversion:

write(1, "Check library libpcre.so.3\n", 27Check library libpcre.so.3
) = 27
newfstatat(AT_FDCWD, "/usr/lib64/libpcre.so.3", 0x7ffdbb3e2d78, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/libpcre.so.3", 0x7ffdbb3e2bc8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpcre.so.3", 0x7ffdbb3e2a18, 0) = -1 ENOENT (No such file or directory)
write(1, "-- Preloading shared libs: :/tmp"..., 259-- Preloading shared libs: :/tmp/.mount_digiKacfD9D2/usr/lib/libavif.so.13:/usr/lib64/libxcb-dri3.so.0:/usr/lib64/libcrypto.so.1.1:/usr/lib64/libssl.so.1.1:/usr/lib64/libnss3.so:/usr/lib64/libnssutil3.so:/usr/lib64/libsmime3.so:/usr/lib64/libgmodule-2.0.so.0

I had to create a manual symlink, preloading didn't work. Is that an appimage issue or something set for digiKam?
Comment 4 caulier.gilles 2022-11-10 09:18:00 UTC
For the AppImage, it build under Ubuntu 18.04. This can explain the libpcre stuff...

Gilles Caulier
Comment 5 Maik Qualmann 2022-11-10 09:39:19 UTC
We know the crash some time ago from here: Bug 415685 Comment 13
I think the cause may be clear. There is a small window of time when ItemInfoData is deleted and we still use it.

Maik
Comment 6 Maik Qualmann 2022-11-10 17:35:50 UTC
Git commit be0c55cde9367f73c091a74708578adc8125f169 by Maik Qualmann.
Committed on 10/11/2022 at 17:34.
Pushed by mqualmann into branch 'master'.

consistently use QExplicitlySharedDataPointer

M  +29   -18   core/libs/database/item/containers/iteminfocache.cpp
M  +7    -7    core/libs/database/item/containers/iteminfocache.h

https://invent.kde.org/graphics/digikam/commit/be0c55cde9367f73c091a74708578adc8125f169
Comment 7 Maik Qualmann 2022-11-10 19:38:19 UTC
Git commit e3b82147f2c0c2364b9de047dfa6b315eaf57a54 by Maik Qualmann.
Committed on 10/11/2022 at 19:37.
Pushed by mqualmann into branch 'qt5-maintenance'.

sync with master

M  +29   -18   core/libs/database/item/containers/iteminfocache.cpp
M  +7    -7    core/libs/database/item/containers/iteminfocache.h

https://invent.kde.org/graphics/digikam/commit/e3b82147f2c0c2364b9de047dfa6b315eaf57a54