Bug 168839 - digikam crashed after tagging
Summary: digikam crashed after tagging
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Tags-Engine (show other bugs)
Version: 0.10.0
Platform: unspecified Linux
: NOR crash
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-10 10:04 UTC by Ferdinand Gassauer
Modified: 2012-06-27 11:30 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 0.10.0


Attachments
fix (455 bytes, patch)
2008-08-10 13:13 UTC, Andi Clemens
Details
still crashing (2.10 KB, patch)
2008-08-11 15:57 UTC, Andi Clemens
Details
trace (2.78 KB, text/plain)
2008-08-20 23:57 UTC, Ferdinand Gassauer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ferdinand Gassauer 2008-08-10 10:04:11 UTC
Version:           0.10.0-beta2 (using 4.1.1 (KDE 4.1.0 (4.1 >= 20080722)) "release 26.2", KDE:KDE4:Factory:Desktop / openSUSE_10.3)
Compiler:          gcc
OS:                Linux (x86_64) release 2.6.22.18-0.2-default

the images are tagged but the app crashed after tagging

Application: digiKam (digikam), signal SIGSEGV
[?1034hUsing host libthread_db library "/lib64/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread 0x2ab7aa2b1030 (LWP 16507)]
[New Thread 0x4580a950 (LWP 16574)]
[New Thread 0x45009950 (LWP 16572)]
[New Thread 0x44808950 (LWP 16570)]
[New Thread 0x44007950 (LWP 16568)]
[New Thread 0x43806950 (LWP 16567)]
[New Thread 0x43005950 (LWP 16562)]
[New Thread 0x42804950 (LWP 16561)]
[New Thread 0x42003950 (LWP 16558)]
[New Thread 0x41001950 (LWP 16555)]
[New Thread 0x41802950 (LWP 16554)]
[New Thread 0x40800950 (LWP 16508)]
[KCrash handler]
#5  0x00002ab7a0bd1052 in QWidgetAction::releaseWidget ()
   from /usr/lib64/libQtGui.so.4
#6  0x00002ab7a0eb99cd in QMenu::~QMenu () from /usr/lib64/libQtGui.so.4
#7  0x00002ab79ca6c390 in QObjectPrivate::deleteChildren ()
   from /usr/lib64/libQtCore.so.4
#8  0x00002ab7a0bc5bcb in QWidget::~QWidget () from /usr/lib64/libQtGui.so.4
#9  0x00002ab7a0eb9358 in QMenu::~QMenu () from /usr/lib64/libQtGui.so.4
#10 0x0000000000664601 in Digikam::TagsPopupMenu::~TagsPopupMenu ()
#11 0x00000000005b08a1 in Digikam::AlbumIconView::slotRightButtonClicked ()
#12 0x00000000005b2e5d in Digikam::AlbumIconView::qt_metacall ()
#13 0x00002ab79ca6ec8b in QMetaObject::activate ()
   from /usr/lib64/libQtCore.so.4
#14 0x0000000000625df5 in Digikam::IconView::signalRightButtonClicked ()
#15 0x0000000000628905 in Digikam::IconView::contentsMousePressEvent ()
#16 0x00002ab7a4971e09 in Q3ScrollView::viewportMousePressEvent ()
   from /usr/lib64/libQt3Support.so.4
#17 0x00002ab7a4973af2 in Q3ScrollView::eventFilter ()
   from /usr/lib64/libQt3Support.so.4
#18 0x00002ab79ca5f20e in QCoreApplicationPrivate::sendThroughObjectEventFilters () from /usr/lib64/libQtCore.so.4
#19 0x00002ab7a0b85650 in QApplicationPrivate::notify_helper ()
   from /usr/lib64/libQtGui.so.4
#20 0x00002ab7a0b8c28b in QApplication::notify () from /usr/lib64/libQtGui.so.4
#21 0x00002ab79d571a6b in KApplication::notify () from /usr/lib64/libkdeui.so.5
#22 0x00002ab79ca5f2f4 in QCoreApplication::notifyInternal ()
   from /usr/lib64/libQtCore.so.4
#23 0x00002ab7a0b8bd13 in QApplicationPrivate::sendMouseEvent ()
   from /usr/lib64/libQtGui.so.4
#24 0x00002ab7a0bdf827 in QETWidget::translateMouseEvent ()
   from /usr/lib64/libQtGui.so.4
#25 0x00002ab7a0bdea9b in QApplication::x11ProcessEvent ()
   from /usr/lib64/libQtGui.so.4
#26 0x00002ab7a0c00d12 in QEventDispatcherX11::processEvents ()
   from /usr/lib64/libQtGui.so.4
#27 0x00002ab79ca5e6b5 in QEventLoop::processEvents ()
   from /usr/lib64/libQtCore.so.4
#28 0x00002ab79ca5e827 in QEventLoop::exec () from /usr/lib64/libQtCore.so.4
#29 0x00002ab79ca607d1 in QCoreApplication::exec ()
   from /usr/lib64/libQtCore.so.4
#30 0x000000000063e5ec in main ()
#0  0x00002ab7a71c46a1 in nanosleep () from /lib64/libc.so.6
Comment 1 Ferdinand Gassauer 2008-08-10 10:05:59 UTC
btw this happens after every tagging
Comment 2 caulier.gilles 2008-08-10 12:07:08 UTC
The crash is not very unstructive. It sound like a broken package... update or compile digiKam yourself and try again. (the crash is not reproductible here)

Thanks in advance

Gilles Caulier

Comment 3 Andi Clemens 2008-08-10 12:54:22 UTC
Gilles,

I can confirm this, too. It happens when deleting "assignTagsPopup". But for me digiKam code looks normal... strangely it doesn't happen when deleting "removeTagsPopup"... I will compare the code line by line to find any difference.

Andi
Comment 4 Andi Clemens 2008-08-10 13:07:48 UTC
Hmm there is nothing to compare at all, both items are the same class (TagsPopupMenu) and both are initialized identically. I have no clue what is happening here. I changed the deletion order of the two TagsPopupMenu objects, but still it crashes when deleting "assignTagsPopup". So it is not an issue of the removal order.
Since both objects are QObject classes, can't we just remove those delete lines? I thought Qt will handle it be itself and you should never use delete on such objects. When removing those lines, it is working again. Maybe we delete too much here?

Andi
Comment 5 Andi Clemens 2008-08-10 13:13:58 UTC
Created attachment 26766 [details]
fix

Do we really need to delete Q objects here? Without it everything works fine
again...

Andi
Comment 6 caulier.gilles 2008-08-10 15:28:48 UTC
Andi,

No, we don't need to delete these items here using QT4. I think this code is sequel from Qt3 version of digiKam which can give a side effect in Qt4. I think we have another code like this to remove later, if another report like this are registered.

So for me, it's fine to apply your patch. Just to be sure, try with valgrind if no memory leak appear. If no. go ahead (:=)))

Gilles
Comment 7 Andi Clemens 2008-08-10 17:59:56 UTC
I always thought Q objects (Qt3 and Qt4) are never removed by the user via the delete command, but removing the four lines in the above patch will create memory leaks.
I don't understand why I can delete the removeTag menu but not the assign tag menu... it always crashes. Maybe it is not working because TagsPopupMenu doesn't have a parent widget in the constructor...
Comment 8 Andi Clemens 2008-08-11 15:57:18 UTC
Created attachment 26782 [details]
still crashing

I don't know what to do about this... I changed all TagPopupMenu lines in this
patch and removed the "new" operator.
Still it crashes and the stack trace tells me that it is trying to delete a
TagPopupMenu (and strangely it calls ~QMenu twice...).

Gilles, Marcel,

any idea? It shouldn't crash now because the menus are not called with new
anymore and the KActions also have a parent, so they should be removed
correctly by Qt itself.
The good thing: No memory leak anymore :-) But with digiKam crashing this is a
bad compromise.
Comment 9 Andi Clemens 2008-08-12 12:34:49 UTC
Ferdinand,

do you have upgraded Qt in the last time? I did so on 07-08-2008 from Qt 4.4.0 to 4.4.1. Maybe this is the reason? For me it looks like a Qt problem, not a digiKam problem because whatever I do here it crashes, although no memory leaks or null pointer issues can be detected.
What Qt version are you running? If you also have 4.4.1 installed, we might have to contact Trolltech about this.
Comment 10 Ferdinand Gassauer 2008-08-12 16:00:23 UTC
here I have libqt4-4.4.1-6.1
Comment 11 Andi Clemens 2008-08-12 16:07:17 UTC
Do you know when you have updated it from 4.4.0 to 4.4.1?
Gilles, do you run Qt 4.4.0?
So maybe this is an Qt issue, because the source code looks alright, and if you remove all "new" operators and create "normal" objects, it still crashes, although these objects should be deleted correctly when leaving the slot.
Comment 12 caulier.gilles 2008-08-12 16:12:04 UTC
Andy,

Sorry for the delay. I'm just back from Akademy. A great event. Last time, you and Marcel you must come to this event and present your work into digiKam project (:=)))

Here i use Qt 4.4.1 with unstable Mandriva 2009-beta1 + cooker repository (KDE 4.1).

else, stable Mandriva 2008.1 use Qt 4.3.3 (KDE 4.0.3)

Gilles
Comment 13 Andi Clemens 2008-08-12 16:29:06 UTC
Nice that you had a great time... normally I would have been on my way to 
norway now :-( but you know my car also is broken... damn... (so there is no 
holiday or Akademy this year). But maybe next time I will be able to come to 
Akademy... 

Damn so this is no Qt problem? I don't get it. This is very strange, even with 
this new patch it will crash (although it shouldn't, but maybe I'm wrong 
here, memory management has never been the topic I'm good at, I come from a 
python background where you don't have to deal with those things...).

And I still don't get why it calls ~QMenu() twice, although the TagPopupMenus 
have no children... so what is it doing... hmm... and why only assignTagsMenu 
and not the other...? question upon question... :-)

Andi
Comment 14 caulier.gilles 2008-08-12 16:40:09 UTC
Andi,

In case of crash, what valgrind backtrace report exactly ?

If crash appears about delete operation, the backtrace come from internal Qt4 or still into digiKam code ?

Gilles
Comment 15 Andi Clemens 2008-08-12 17:41:59 UTC
This is what I get from valgrind:

==10925== Invalid read of size 4
==10925==    at 0x5DE73F2: QWidgetAction::releaseWidget(QWidget*) (in /usr/lib/libQtGui.so.4.4.1)
==10925==    by 0x60EA774: QMenu::~QMenu() (in /usr/lib/libQtGui.so.4.4.1)
==10925==    by 0x58D0324: QObjectPrivate::deleteChildren() (in /usr/lib/libQtCore.so.4.4.1)
==10925==    by 0x5DE294A: QWidget::~QWidget() (in /usr/lib/libQtGui.so.4.4.1)
==10925==    by 0x60E8377: QMenu::~QMenu() (in /usr/lib/libQtGui.so.4.4.1)
==10925==    by 0x82F736E: Digikam::TagsPopupMenu::~TagsPopupMenu() (tagspopupmenu.cpp:404)
==10925==    by 0x8228ED0: Digikam::AlbumIconView::slotRightButtonClicked(Digikam::IconItem*, QPoint const&) (albumiconview.cpp:797)
==10925==    by 0x82295A2: Digikam::AlbumIconView::qt_metacall(QMetaObject::Call, int, void**) (albumiconview.moc:190)
==10925==    by 0x58D48D6: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/libQtCore.so.4.4.1)
==10925==    by 0x58D4DEC: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (in /usr/lib/libQtCore.so.4.4.1)
==10925==    by 0x82AFF66: Digikam::IconView::signalRightButtonClicked(Digikam::IconItem*, QPoint const&) (iconview.moc:113)
==10925==    by 0x82B2834: Digikam::IconView::contentsMousePressEvent(QMouseEvent*) (iconview.cpp:953)
==10925==  Address 0xa22596c is 4 bytes inside a block of size 12 free'd
==10925==    at 0x402272A: operator delete(void*) (in /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so)
==10925==    by 0x82FAE1B: Digikam::TagToggleAction::~TagToggleAction() (tagspopupmenu.cpp:69)
==10925==    by 0x58D0324: QObjectPrivate::deleteChildren() (in /usr/lib/libQtCore.so.4.4.1)
==10925==    by 0x58D7A03: QObject::~QObject() (in /usr/lib/libQtCore.so.4.4.1)
==10925==    by 0x5D970AF: QActionGroup::~QActionGroup() (in /usr/lib/libQtGui.so.4.4.1)
==10925==    by 0x58D0324: QObjectPrivate::deleteChildren() (in /usr/lib/libQtCore.so.4.4.1)
==10925==    by 0x5DE294A: QWidget::~QWidget() (in /usr/lib/libQtGui.so.4.4.1)
==10925==    by 0x60E8377: QMenu::~QMenu() (in /usr/lib/libQtGui.so.4.4.1)
==10925==    by 0x82F736E: Digikam::TagsPopupMenu::~TagsPopupMenu() (tagspopupmenu.cpp:404)
==10925==    by 0x8228ED0: Digikam::AlbumIconView::slotRightButtonClicked(Digikam::IconItem*, QPoint const&) (albumiconview.cpp:797)
==10925==    by 0x82295A2: Digikam::AlbumIconView::qt_metacall(QMetaObject::Call, int, void**) (albumiconview.moc:190)
==10925==    by 0x58D48D6: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/libQtCore.so.4.4.1)


It is the same backtrace as from GDB.

I used valgrind with those options:

valgrind  --tool=memcheck --leak-check=yes --db-attach=yes --suppressions=digikam4.sup /usr/bin/digikam
Comment 16 caulier.gilles 2008-08-12 19:42:13 UTC
Andi,

Sound like a similar problem that i have fixed in a past with this commit :

http://websvn.kde.org/?view=rev&revision=787473

Using deleteLater() must fix the problem

Gilles
Comment 17 caulier.gilles 2008-08-12 19:45:31 UTC
Andy,


>And I still don't get why it calls ~QMenu() twice, although the TagPopupMenus
>have no children... so what is it doing... hmm... and why only assignTagsMenu
>and not the other...? question upon question... :-) 

Well it's simple to understand: it's a race condition with Qt when it delete internal menu contents. If menu is big it take a while else it's very fast.

When we delete menu in digiKam before than Qt have deleted internal component, we have a crash. Note this problem is specific to Qt4. With Wt3 i have never seen that.

There is a lots of place where tagpopupmenu is used and deleted by hand. All these codes need to be fixed by this way.

Gilles
Comment 18 Andi Clemens 2008-08-12 19:52:34 UTC
Gilles,

I'm sorry but this doesn't seem to fix the problem, I just tried it. But maybe 
I need to call this on the popupmenu (the main menu so to say)...? I'll try 
this, too.
Comment 19 Andi Clemens 2008-08-12 19:57:46 UTC
Ok now it seems to work... I removed the "new" operator again, removed all delete lines and just call deleteLater() on popupmenu...
Comment 20 Andi Clemens 2008-08-12 20:08:31 UTC
SVN commit 845962 by aclemens:

this fix should prevent a race condition when deleting the context popup menu

CCBUGS:168839

 M  +35 -38    albumiconview.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=845962
Comment 21 Andi Clemens 2008-08-12 20:08:31 UTC
Ah damn it is not working when using "normal" objects... strange... all the 
other menus are not defined with "new" operator and they work. I'll commit 
the fixed version WITH the "new" operator now.

Ferdinand,
can you please test the latest SVN to see if it is fixed?
Comment 22 Andi Clemens 2008-08-20 23:31:57 UTC
Any updates here?
Ferdinand, is it fixed for you so we can close this one?

Andi
Comment 23 Ferdinand Gassauer 2008-08-20 23:56:09 UTC
kde4-digikam-0.10.0-16.13 SuSE 10.3

I even didn't tag a pciture, I just clicked somewhere between the images 

QPainter::begin: A paint device can only be painted by one painter at a time.
QPainter::begin: A paint device can only be painted by one painter at a time.
KCrash: Application 'digikam' crashing...
sock_file=/home/kdesvn/.kde4/socket-cc-gf2/kdeinit4__0
Comment 24 Ferdinand Gassauer 2008-08-20 23:57:26 UTC
Created attachment 26952 [details]
trace
Comment 25 Andi Clemens 2008-08-21 00:16:37 UTC
I can't confirm this... you clicked between the thumbnails and digiKam crashed? Right now? With the current SVN checkout?
Left- or Right-click?

Andi
Comment 26 caulier.gilles 2008-08-21 06:11:38 UTC
>QPainter::begin: A paint device can only be painted by one painter at a time. >KCrash: Application 'digikam' crashing... >sock_file=/home/kdesvn/.kde4/socket-cc-gf2/kdeinit4__0

Ferdinand : i have fixed normally this problem with current implementation from svn (0.10.0-beta3)

Gilles Caulier
Comment 27 Ferdinand Gassauer 2008-08-21 08:08:27 UTC
SuSE Factory has beta 2 currently - should be picked up soon I assume.
I'll check then.
Or pls provide the link to SVN, don't have time to search now
Comment 28 caulier.gilles 2008-08-21 08:22:25 UTC
Ferdinand,

Look here : http://www.digikam.org/drupal/download/svn

Gilles Caulier
Comment 29 Andi Clemens 2008-08-21 09:03:47 UTC
Gilles,

but the QPainter issue shouldn't be the problem here, I also had this a lot but digiKam never crashed. Maybe I'm wrong... 

Ferdinand,
you said you are using beta2? So you can't have this patch installed yet. As Gilles mentioned, please try to compile for yourself or wait for beta3 from openSUSE...

Andi
Comment 30 Ferdinand Gassauer 2008-08-21 10:09:59 UTC
Version 0.10.0-beta3 (rev.: 850265) works for me
thanks - it's really a great tool .....

BTW IMHO the tag bar (left side) shouldn't have a fixed minimum width

Comment 31 Andi Clemens 2008-08-21 10:12:52 UTC
Since we patched it FIXED should be used instead of WORKSFORME.