Bug 420411

Summary: digiKam Crash on detect faces 7.0.0 beta3 debug build
Product: [Applications] digikam Reporter: Stefan S <stefan.szekeres>
Component: Faces-DetectionAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: caulier.gilles, metzpinguin
Priority: NOR    
Version: 7.0.0   
Target Milestone: ---   
Platform: macOS (DMG)   
OS: macOS   
Latest Commit: Version Fixed In: 7.2.0
Sentry Crash Report:

Description Stefan S 2020-04-22 09:30:05 UTC
SUMMARY
When scanning for faces, digiKam instantly crashes

STEPS TO REPRODUCE
1. connect network drive with photos under /Volumes/photos
2. go to people tab
3. select scan again and merge results, Detect Faces, search in: Whole albums collection, work on all processors, face accuracy 85% 
4. Scan collection for faces

OBSERVED RESULT
Crash 50% reproduction rate

EXPECTED RESULT
no crash

Process:               digikam [76962]
Path:                  /opt/digikam/*/digikam.app/Contents/MacOS/digikam
Identifier:            digikam
Version:               7.0.0 (7.0.0-beta3)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           digikam [76962]
User ID:               501

Date/Time:             2020-04-22 12:16:11.662 +0300
OS Version:            Mac OS X 10.14.5 (18F132)
Report Version:        12
Bridge OS Version:     3.0 (14Y901)
Anonymous UUID:        640A05BC-CE71-FC62-2810-57378A7673CE

Sleep/Wake UUID:       63D298DB-2A41-4C53-A8B2-4A0DF4E9047A

Time Awake Since Boot: 400000 seconds
Time Since Wake:       5600 seconds

System Integrity Protection: disabled

Crashed Thread:        32  Thread (pooled)

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000038
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Segmentation fault: 11
Termination Reason:    Namespace SIGNAL, Code 0xb
Terminating Process:   exc handler [76962]

VM Regions Near 0x38:
--> 
    __TEXT                 0000000106219000-0000000106227000 [   56K] r-x/r-x SM=COW  /opt/digikam/*/digikam.app/Contents/MacOS/digikam

Thread 0:: CrBrowserMain  Dispatch queue: com.apple.main-thread
0   libsystem_malloc.dylib        	0x00007fff59b5329e nanov2_allocate_from_block + 282
1   libsystem_malloc.dylib        	0x00007fff59b52a61 nanov2_allocate + 130
2   libsystem_malloc.dylib        	0x00007fff59b5298e nanov2_malloc + 56
3   libsystem_malloc.dylib        	0x00007fff59b45dfd malloc_zone_malloc + 103
4   libsystem_malloc.dylib        	0x00007fff59b45d79 malloc + 24
5   libc++abi.dylib               	0x00007fff56c1a378 operator new(unsigned long) + 40
6   org.qt-project.QtCore         	0x000000010ab4cd16 QObject::QObject(QObject*) + 34
7   libdigikamcore.7.0.0.dylib    	0x0000000107df6d1d Digikam::WorkerObject::WorkerObject() + 29
8   libdigikamgui.7.0.0.dylib     	0x000000010676c180 Digikam::DetectionWorker::DetectionWorker(Digikam::FacePipeline::Private*) + 32
9   libdigikamgui.7.0.0.dylib     	0x000000010676c1ed Digikam::DetectionWorker::DetectionWorker(Digikam::FacePipeline::Private*) + 29
10  libdigikamgui.7.0.0.dylib     	0x00000001067564b4 Digikam::FacePipeline::plugParallelFaceDetectors() + 196
11  libdigikamgui.7.0.0.dylib     	0x000000010660f4c4 Digikam::FacesDetector::FacesDetector(Digikam::FaceScanSettings const&, Digikam::ProgressItem*) + 1220
12  libdigikamgui.7.0.0.dylib     	0x00000001066100a5 Digikam::FacesDetector::FacesDetector(Digikam::FaceScanSettings const&, Digikam::ProgressItem*) + 37
13  libdigikamgui.7.0.0.dylib     	0x0000000106372953 Digikam::PeopleSideBarWidget::slotScanForFaces() + 131
14  libdigikamgui.7.0.0.dylib     	0x000000010624de54 Digikam::PeopleSideBarWidget::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 164
15  org.qt-project.QtCore         	0x000000010ab524bc 0x10a9fe000 + 1393852
16  org.qt-project.QtWidgets      	0x000000010a289c35 0x10a1dd000 + 707637
17  org.qt-project.QtWidgets      	0x000000010a28a467 QAbstractButton::mousePressEvent(QMouseEvent*) + 93
18  org.qt-project.QtWidgets      	0x000000010a21151a QWidget::event(QEvent*) + 1714
19  org.qt-project.QtWidgets      	0x000000010a1e9ab6 QApplicationPrivate::notify_helper(QObject*, QEvent*) + 218
20  org.qt-project.QtWidgets      	0x000000010a1ebee7 QApplication::notify(QObject*, QEvent*) + 6019
21  org.qt-project.QtCore         	0x000000010ab33774 QCoreApplication::notifyInternal2(QObject*, QEvent*) + 138
22  org.qt-project.QtWidgets      	0x000000010a1ea1dd QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) + 701
23  org.qt-project.QtWidgets      	0x000000010a2246ef 0x10a1dd000 + 292591
24  org.qt-project.QtWidgets      	0x000000010a223b1f 0x10a1dd000 + 289567
25  org.qt-project.QtWidgets      	0x000000010a1e9ab6 QApplicationPrivate::notify_helper(QObject*, QEvent*) + 218
26  org.qt-project.QtWidgets      	0x000000010a1eaa32 QApplication::notify(QObject*, QEvent*) + 718
27  org.qt-project.QtCore         	0x000000010ab33774 QCoreApplication::notifyInternal2(QObject*, QEvent*) + 138
28  org.qt-project.QtGui          	0x000000010a66b37d QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 1437
29  org.qt-project.QtGui          	0x000000010a65d325 QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 93
30  libqcocoa.dylib               	0x000000011df00ae6 0x11ded2000 + 191206
31  libqcocoa.dylib               	0x000000011df0108c 0x11ded2000 + 192652
32  com.apple.CoreFoundation      	0x00007fff2da8a083 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
33  com.apple.CoreFoundation      	0x00007fff2da8a029 __CFRunLoopDoSource0 + 108
34  com.apple.CoreFoundation      	0x00007fff2da6d9eb __CFRunLoopDoSources0 + 195
35  com.apple.CoreFoundation      	0x00007fff2da6cfb5 __CFRunLoopRun + 1189
36  com.apple.CoreFoundation      	0x00007fff2da6c8be CFRunLoopRunSpecific + 455
37  com.apple.HIToolbox           	0x00007fff2cd5896b RunCurrentEventLoopInMode + 292
38  com.apple.HIToolbox           	0x00007fff2cd585ad ReceiveNextEventCommon + 355
39  com.apple.HIToolbox           	0x00007fff2cd58436 _BlockUntilNextEventMatchingListInModeWithFilter + 64
40  com.apple.AppKit              	0x00007fff2b0f2987 _DPSNextEvent + 965
41  com.apple.AppKit              	0x00007fff2b0f171f -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
42  com.apple.AppKit              	0x00007fff2b0eb83c -[NSApplication run] + 699
43  libqcocoa.dylib               	0x000000011df00332 0x11ded2000 + 189234
44  org.qt-project.QtCore         	0x000000010ab31517 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 267
45  org.qt-project.QtCore         	0x000000010ab33bc3 QCoreApplication::exec() + 123
46  digikam                       	0x00000001062235a5 main + 11877
47  libdyld.dylib                 	0x00007fff5999b3d5 start + 1

Thread 32 Crashed:: Thread (pooled)
0   org.qt-project.QtCore         	0x000000010ab4ce0c QObject::thread() const + 12
1   libdigikamcore.7.0.0.dylib    	0x0000000107df494c Digikam::ParkingThread::moveToCurrentThread(QObject*) + 300
2   libdigikamcore.7.0.0.dylib    	0x0000000107df4698 Digikam::WorkerObjectRunnable::run() + 56
3   org.qt-project.QtCore         	0x000000010aa1b147 0x10a9fe000 + 119111
4   org.qt-project.QtCore         	0x000000010aa18bd4 0x10a9fe000 + 109524
5   libsystem_pthread.dylib       	0x00007fff59b8f2eb _pthread_body + 126
6   libsystem_pthread.dylib       	0x00007fff59b92249 _pthread_start + 66
7   libsystem_pthread.dylib       	0x00007fff59b8e40d thread_start + 13



SOFTWARE/OS VERSIONS
Build date: Apr 19 2020 (target: Debug)
Rev.: 3f079531b1116827cec535fa8c0bbdc45e43766c

qt: stable 5.14.1 (bottled), HEAD [keg-only]
Cross-platform application and UI framework
https://www.qt.io/
/usr/local/Cellar/qt/5.14.1 (10,389 files, 363.0MB)
  Poured from bottle on 2020-04-01 at 22:47:57

macOS 10.14.5 (18F132)

ADDITIONAL INFORMATION
full crash log: https://gist.github.com/0wnrepo/fd8de03b7ac5fc7443bd25886f05a16e

Personal notes: should not be doing work on main thread, that blocks the GUI - can't open digiKam after it starts detecting.
Comment 1 caulier.gilles 2020-04-22 09:51:37 UTC
>Personal notes: should not be doing work on main thread, that blocks the GUI - >can't open digiKam after it starts detecting.

I don't understand this point : all long process are started in separated thread under DK.

Gilles Caulier
Comment 2 Stefan S 2020-04-22 15:56:55 UTC
(In reply to caulier.gilles from comment #1)
> >Personal notes: should not be doing work on main thread, that blocks the GUI - >can't open digiKam after it starts detecting.
> 
> I don't understand this point : all long process are started in separated
> thread under DK.
> 
> Gilles Caulier

They are not, at least not all of them, if you look at 
Thread 0:: CrBrowserMain  Dispatch queue: com.apple.main-thread
You are doing face detection on the main thread (thread 0) as far as i can see.
And there other places in your code where everything is done on the main thread, like here: https://bugs.kde.org/show_bug.cgi?id=420334#c12
Comment 3 Maik Qualmann 2020-07-12 07:04:21 UTC
Git commit b66eb0a0556388fc532fcc5bba7a40ed6eda2fc1 by Maik Qualmann.
Committed on 12/07/2020 at 06:58.
Pushed by mqualmann into branch 'master'.

disable OpenCL for everyone
An analysis with Heaptrack shows that we
have a big memory leak with active OpenCL.
Related: bug 423632, bug 421043, bug 416266

M  +10   -0    core/app/main/main.cpp
M  +0    -5    project/bundles/appimage/data/AppRun

https://invent.kde.org/graphics/digikam/commit/b66eb0a0556388fc532fcc5bba7a40ed6eda2fc1
Comment 4 caulier.gilles 2020-07-14 09:31:34 UTC
Hi,

Can you check if this crash still exist with last weekly AppImage build
available here :

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

Thanks in advance
Comment 5 caulier.gilles 2020-07-30 09:45:15 UTC
digiKam 7.0.0 stable release is now published:

https://www.digikam.org/news/2020-07-19-7.0.0_release_announcement/

We need a fresh feedback on this file using this version.

Thanks in advance

Gilles Caulier
Comment 6 Maik Qualmann 2020-10-03 19:45:20 UTC
Fixed with bug 426175.

Maik