Bug 286719 - Digikam hang during startup (deadlock?)
Summary: Digikam hang during startup (deadlock?)
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Database-Scan (show other bugs)
Version: 2.3.0
Platform: Gentoo Packages Linux
: NOR crash
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-15 18:35 UTC by Oldřich Jedlička
Modified: 2017-07-25 13:19 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 2.7.0
Sentry Crash Report:


Attachments
Thread dump (11.72 KB, text/plain)
2011-11-15 18:35 UTC, Oldřich Jedlička
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oldřich Jedlička 2011-11-15 18:35:05 UTC
Created attachment 65720 [details]
Thread dump

Version:           2.3.0 (using KDE 4.7.3) 
OS:                Linux

When I start Digikam from quick action when I plug my camera, it hangs during startup. From the backtrace (attached) it looks like there is a deadlock.



Reproducible: Didn't try

Steps to Reproduce:
Click on "Download pictures using Digikam" when the Camera appears on screen. 

Actual Results:  
Digikam hangs during startup.

Expected Results:  
Digikam starts.
Comment 1 Oldřich Jedlička 2011-11-15 18:40:27 UTC
The command line looks like: digikam --download-from-udi /org/kde/solid/udev/sys/devices/pci0000:00/0000:00:1d.0/usb6/6-1
Comment 2 caulier.gilles 2011-11-15 19:41:12 UTC
Which camera do you plug ? Do you use gphoto2 camera, as Canon for ex ?

Gilles Caulier
Comment 3 Oldřich Jedlička 2011-11-15 19:56:07 UTC
I've restarted and the hang-up happens also without the Camera plugged. Anyway, I have gphoto2 camera, Canon PowerShort S60.
Comment 4 Oldřich Jedlička 2011-11-15 20:02:57 UTC
I can analyse the problem more in depth, but currently I'm not much familiar with Qt/KDE. I see DatabaseAccess::DatabaseAccess waiting for lock on Thread 1 and from code also an acquired lock on DatabaseAccess::checkReadyForUse on Thread 4. Thread 4 is waiting on some "emit" code (blocking_activate), which I don't know how works. So the problem is that Thread 1 cannot continue, because Thread 4 has the lock. Thread 4 cannot continue, because it waits for something.
Comment 5 Oldřich Jedlička 2011-11-16 07:35:28 UTC
I've checked the CollectionManager::updateLocations (Thread 4):

The need to have class DatabaseAccessUnlock points to the real problem - the locking is screwed. If there are methods that need to have the database unlocked then they should be called as such.

Moreover, the DatabaseAccessUnlock is written for multi-threaded environment. The constructor frees all locks, but there is no guarantee that the lock will be obtained from other thread after the constructor returns. This just cannot work without locking...

I think this class is dangerous in the way it cannot actually do what it declares, so it should be removed and the methods fixed. Maybe the CollectionManagerPrivate::listVolumes method could be revised for thread-safety with KDE 4.7 again (according to the comment inside the method).
Comment 6 Marcel Wiesweg 2011-11-16 20:38:35 UTC
The important point is that the current thread, which intends to block on an event loop mutex, drops the DatabaseAccess recursive mutex before. Any other thread may acquire the DatabaseAccess mutex at will. It seems that the unlocking does not work though - apparently, the mutex is locked. It's a special case of a Solid event delivered during the startup phase.
What we should reconsider is the dependence of CollectionManager on DatabaseAccess as a "big lock", which adds this complexity.
Comment 7 Oldřich Jedlička 2011-11-29 17:05:58 UTC
Removing any (unnecessary) dependency from the database access layer looks more than reasonable. From the architecture point of view the database access layer should do the database access and nothing more.
Comment 8 caulier.gilles 2012-06-22 08:49:53 UTC
Official digiKam 2.6.0 release is out since few days now :

http://www.digikam.org/drupal/node/656

Please, check if this entry still valid, or update report accordingly.

Thanks in advance.

Gilles Caulier
Comment 9 Oldřich Jedlička 2012-06-25 17:39:04 UTC
Works for me with 2.6.0.