[Digikam-devel] Crash During Complete Scan With Many Pictures

Todd Goodman tsg at bonedaddy.net
Thu Aug 26 13:10:40 BST 2010


I had reported before that I was unable to get past the complete scan at
initial startup without crashing.  (Sorry, I couldn't find the bug
searching bugzilla.)

The latest incarnation of this crash was the memory issue in attached
kcrash.

I made the changes in the attached diff and was able to finally start up
and use digikam.

I make no claims that the patch is the "right" way to fix this issue or
even that it's not a dangerous change (the seperate transactions might
be an issue.)

But I thought it might provide more information about the problem I was
having.

This is patched against a recent svn build.

Todd
-------------- next part --------------
Index: libs/database/collectionscanner.h
===================================================================
--- libs/database/collectionscanner.h	(revision 1156900)
+++ libs/database/collectionscanner.h	(working copy)
@@ -59,6 +59,7 @@
     CollectionScanner();
     ~CollectionScanner();
 
+    void completeScanWorker(const CollectionLocation &location);
     /**
      * Carries out a full scan on all available parts of the collection.
      * Only a full scan can finally remove deleted files from the database,
Index: libs/database/collectionscanner.cpp
===================================================================
--- libs/database/collectionscanner.cpp	(revision 1156900)
+++ libs/database/collectionscanner.cpp	(working copy)
@@ -203,6 +203,14 @@
     d->observer = observer;
 }
 
+void CollectionScanner::completeScanWorker(const CollectionLocation &location)
+{
+    // lock database
+    DatabaseTransaction transaction;
+
+    scanAlbumRoot(location);
+}
+
 void CollectionScanner::completeScan()
 {
     QTime time;
@@ -210,12 +218,6 @@
 
     emit startCompleteScan();
 
-    // lock database
-    DatabaseTransaction transaction;
-
-    loadNameFilters();
-    d->resetRemovedItemsTime();
-
     //TODO: Implement a mechanism to watch for album root changes while we keep this list
     QList<CollectionLocation> allLocations = CollectionManager::instance()->allAvailableLocations();
 
@@ -229,6 +231,9 @@
         emit totalFilesToScan(count);
     }
 
+    loadNameFilters();
+    d->resetRemovedItemsTime();
+
     if (!d->checkObserver())
     {
         emit cancelled();
@@ -251,8 +256,16 @@
         emit startScanningAlbumRoots();
 
     foreach (const CollectionLocation& location, allLocations)
-        scanAlbumRoot(location);
+    {
+        completeScanWorker(location);
 
+    	if (!d->checkObserver())
+    	{
+            emit cancelled();
+            return;
+    	}
+    }
+
     // do not continue to clean up without a complete scan!
     if (!d->checkObserver())
     {
@@ -630,10 +643,12 @@
         itemIdSet << scanInfos[i].id;
     }
 
-    const QFileInfoList list = dir.entryInfoList(QDir::AllDirs | QDir::Files  | QDir::NoDotAndDotDot);
+    int counter = -1, totalFiles = 0;
+
+    {
+    const QFileInfoList list = dir.entryInfoList(QDir::Files);
     QFileInfoList::const_iterator fi;
 
-    int counter = -1;
     for (fi = list.constBegin(); fi != list.constEnd(); ++fi)
     {
         if (!d->checkObserver())
@@ -680,8 +695,27 @@
                 }
             }
         }
-        else if ( fi->isDir() )
+    }
+        totalFiles = list.count();
+    }
+    {
+    const QFileInfoList list = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot);
+    QFileInfoList::const_iterator fi;
+
+    for (fi = list.constBegin(); fi != list.constEnd(); ++fi)
+    {
+        if (!d->checkObserver())
+            return; // return directly, do not go to cleanup code after loop!
+
+        counter++;
+        if (d->wantSignals && counter && (counter % 100 == 0))
         {
+            emit scannedFiles(counter);
+            counter = 0;
+        }
+
+        if ( fi->isDir() )
+        {
             QString subalbum;
             if (album == "/")
                 subalbum = '/' + fi->fileName();
@@ -691,6 +725,8 @@
             scanAlbum( location, subalbum );
         }
     }
+        totalFiles += list.count();
+    }
 
     if (d->wantSignals && counter)
         emit scannedFiles(counter);
@@ -706,7 +742,7 @@
     d->scannedAlbums << albumID;
 
     if (d->wantSignals)
-        emit finishedScanningAlbum(location.albumRootPath(), album, list.count());
+        emit finishedScanningAlbum(location.albumRootPath(), album, totalFiles);
 }
 
 void CollectionScanner::scanFileNormal(const QFileInfo& fi, const ItemScanInfo& scanInfo)
-------------- next part --------------
Application: digiKam (/usr/local/bin/digikam), signal: Aborted
[Current thread is 0 (LWP 5082)]

Thread 2 (Thread 0xb1448b90 (LWP 5086)):
[KCrash Handler]
#5  0xffffe424 in __kernel_vsyscall ()
#6  0xb4e9dc41 in raise () from /lib/libc.so.6
#7  0xb4e9f428 in abort () from /lib/libc.so.6
#8  0xb509b794 in __gnu_cxx::__verbose_terminate_handler () from /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6
#9  0xb50991b5 in ?? () from /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6
#10 0xb50991f2 in std::terminate () from /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6
#11 0xb509932a in __cxa_throw () from /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/libstdc++.so.6
#12 0xb51bc855 in qBadAlloc () at global/qglobal.cpp:2003
#13 0xb51e7cb7 in QListData::realloc (this=0x8525188, alloc=2097147) at tools/qlist.cpp:159
#14 0xb51e7d97 in QListData::append (this=0x8525188) at tools/qlist.cpp:179
#15 0xb52d2edf in QList<QPostEvent>::append (this=0x8525188, t=@0xb1447f64) at ../../include/QtCore/../../src/corelib/tools/qlist.h:470
#16 0xb52ce6c2 in QCoreApplication::postEvent (receiver=0x8643300, event=0x2ce7fa50, priority=0) at kernel/qcoreapplication.cpp:1171
#17 0xb52ce82a in QCoreApplication::postEvent (receiver=0x8643300, event=0x2ce7fa50) at kernel/qcoreapplication.cpp:1088
#18 0xb52e1be9 in queued_activate (sender=0x86073d8, signal=4, c=0x8629418, argv=0xb14480cc, semaphore=0x0) at kernel/qobject.cpp:3165
#19 0xb52e44b4 in QMetaObject::activate (sender=0x86073d8, m=0xb6d940c4, local_signal_index=0, argv=<value optimized out>) at kernel/qobject.cpp:3258
#20 0xb6c708de in Digikam::DatabaseWatch::imageChange (this=0x86073d8, _t1=@0xb144815c) at /root/digikam-svn/graphics/digikam/build/digikam/moc_databasewatch.cpp:150
#21 0xb6c70980 in Digikam::DatabaseWatch::sendImageChange (this=0x86073d8, cset=@0xb144815c) at /root/digikam-svn/graphics/digikam/libs/database/databasewatch.cpp:239
#22 0xb6c7792b in Digikam::DatabaseBackendPrivate::sendToWatch (this=0x8609e50, changeset=@0xb144815c) at /root/digikam-svn/graphics/digikam/libs/database/databasebackend_p.h:59
#23 0xb6c77a24 in Digikam::DatabaseBackendPrivate::ChangesetContainer<Digikam::ImageChangeset>::sendOut (this=0x8609eb0) at /root/digikam-svn/graphics/digikam/libs/database/databasebackend_p.h:94
#24 0xb6c77b0e in Digikam::DatabaseBackendPrivate::transactionFinished (this=0x8609e50) at /root/digikam-svn/graphics/digikam/libs/database/databasebackend_p.h:112
#25 0xb6fc89bc in Digikam::DatabaseCoreBackend::commitTransaction (this=0x8608090) at /root/digikam-svn/graphics/digikam/libs/database/databasecorebackend.cpp:1149
#26 0xb6c7832a in ~DatabaseTransaction (this=0xb1448288) at /root/digikam-svn/graphics/digikam/libs/database/databasetransaction.cpp:57
#27 0xb6c5b10b in Digikam::CollectionScanner::completeScan (this=0xb1448328) at /root/digikam-svn/graphics/digikam/libs/database/collectionscanner.cpp:283
#28 0x08348c37 in Digikam::ScanController::run (this=0x8602f78) at /root/digikam-svn/graphics/digikam/digikam/scancontroller.cpp:540
#29 0xb51c5e6a in QThreadPrivate::start (arg=0x8602f78) at thread/qthread_unix.cpp:248
#30 0xb514c19b in start_thread () from /lib/libpthread.so.0
#31 0xb4f3e9ee in clone () from /lib/libc.so.6

Thread 1 (Thread 0xb2a66700 (LWP 5082)):
#0  0xffffe424 in __kernel_vsyscall ()
#1  0xb51508d5 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#2  0xb51c51aa in QMutexPrivate::wait (this=0x8607370, timeout=-1) at thread/qmutex_unix.cpp:84
#3  0xb51c0801 in QMutex::lock (this=0x860734c) at thread/qmutex.cpp:167
#4  0xb6c6d3ed in DatabaseAccess (this=0xbfecb9b7) at /root/digikam-svn/graphics/digikam/libs/database/databaseaccess.cpp:100
#5  0x08345233 in Digikam::ScanControllerLoadingCacheFileWatch::slotImageChanged (this=0x8643300, changeset=@0xb0306b78) at /root/digikam-svn/graphics/digikam/digikam/scancontroller.cpp:830
#6  0x08348787 in Digikam::ScanControllerLoadingCacheFileWatch::qt_metacall (this=0x8643300, _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0xab702e08)
    at /root/digikam-svn/graphics/digikam/build/digikam/scancontroller.moc:72
#7  0xb52d42cb in QMetaObject::metacall (object=0x80, cl=QMetaObject::InvokeMetaMethod, idx=7, argv=0xab702e08) at kernel/qmetaobject.cpp:237
#8  0xb52de374 in QMetaCallEvent::placeMetaCall (this=0xb03069f8, object=0x8643300) at kernel/qobject.cpp:561
#9  0xb52dfb58 in QObject::event (this=0x8643300, e=0xb03069f8) at kernel/qobject.cpp:1240
#10 0xb5919a3f in QApplicationPrivate::notify_helper (this=0x8546118, receiver=0x8643300, e=0xb03069f8) at kernel/qapplication.cpp:4302
#11 0xb591d6d8 in QApplication::notify (this=0xbfecc484, receiver=0x8643300, e=0xb03069f8) at kernel/qapplication.cpp:3736
#12 0xb648494a in KApplication::notify (this=0xbfecc484, receiver=0x8643300, event=0xb03069f8) at /var/tmp/portage/kde-base/kdelibs-4.4.4/work/kdelibs-4.4.4/kdeui/kernel/kapplication.cpp:302
#13 0xb52cdbba in QCoreApplication::notifyInternal (this=0xbfecc484, receiver=0x8643300, event=0xb03069f8) at kernel/qcoreapplication.cpp:726
#14 0xb52cec7c in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x8525170) at kernel/qcoreapplication.h:215
#15 0xb52cef4d in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at kernel/qcoreapplication.cpp:1260
#16 0xb52fb13d in postEventSourceDispatch (s=0x85484a0) at kernel/qcoreapplication.h:220
#17 0xb486e1c2 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#18 0xb48714ef in ?? () from /usr/lib/libglib-2.0.so.0
#19 0x08548420 in ?? ()
#20 0x00000000 in ?? ()


More information about the Digikam-devel mailing list