Bug 173384 - kig crash on exit
Summary: kig crash on exit
Status: RESOLVED FIXED
Alias: None
Product: kig
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR crash
Target Milestone: ---
Assignee: David E. Narvaez
URL:
Keywords:
: 176157 180817 184203 196947 212415 226722 267036 316603 320665 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-10-23 19:16 UTC by Peter Volkov
Modified: 2014-02-13 21:55 UTC (History)
14 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.12.3


Attachments
proposed patch (1.56 KB, patch)
2010-09-13 17:14 UTC, Christoph Feck
Details
New crash information added by DrKonqi (5.49 KB, text/plain)
2011-04-20 19:44 UTC, Ettore Atalan
Details
Proposed patch: cancel construction before quit (1.42 KB, patch)
2014-02-01 16:38 UTC, Jacob Welsh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Volkov 2008-10-23 19:16:14 UTC
Version:           Kig: v1.0 (using KDE 4.1.2)
Compiler:          gcc (Gentoo 4.3.2 p1.0) 4.3.2 
OS:                Linux
Installed from:    Gentoo Packages

Well this was my first start of kig. I just wanted to see what's this application. I did few things, just set point and looked through menu, after that pressed X button on the window to close kig and received crash.

Приложение: Kig (kig), сигнал SIGSEGV
Using host libthread_db library "/lib/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread 0xb808f920 (LWP 8464)]
[KCrash handler]
#6  QAction::setEnabled (this=<value optimized out>, b=<value optimized out>)
    at kernel/qaction.cpp:981
#7  0xb674d8fb in KigMode::enableActions (this=0x9df89b0)
    at /home/portage/tmp/portage/kde-base/kig-4.1.2/work/kig-4.1.2/kig/modes/mode.cc:30
#8  0xb675179e in NormalMode::enableActions (this=0x9df89b0)
    at /home/portage/tmp/portage/kde-base/kig-4.1.2/work/kig-4.1.2/kig/modes/normal.cc:47
#9  0xb67989a8 in KigPart::setMode (this=0x9dfaa38, m=0x9df89b0)
    at /home/portage/tmp/portage/kde-base/kig-4.1.2/work/kig-4.1.2/kig/kig/kig_part.cpp:511
#10 0xb6798c87 in KigPart::runMode (this=0x9dfaa38, m=0x9f28f30)
    at /home/portage/tmp/portage/kde-base/kig-4.1.2/work/kig-4.1.2/kig/kig/kig_part.cpp:677
#11 0xb671770d in ConstructibleAction::act (this=0x9e4e728, d=@0x9dfaa38)
    at /home/portage/tmp/portage/kde-base/kig-4.1.2/work/kig-4.1.2/kig/misc/guiaction.cc:80
#12 0xb6716f9b in KigGUIAction::slotActivated (this=0x9e80b98)
    at /home/portage/tmp/portage/kde-base/kig-4.1.2/work/kig-4.1.2/kig/misc/guiaction.cc:106
#13 0xb6717795 in KigGUIAction::qt_metacall (this=0x9e80b98, 
    _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0xbfaa80cc)
    at /home/portage/tmp/portage/kde-base/kig-4.1.2/work/kig_build/kig/guiaction.moc:65
#14 0x4d7a428a in QMetaObject::activate (sender=<value optimized out>, 
    from_signal_index=<value optimized out>, 
    to_signal_index=<value optimized out>, argv=<value optimized out>)
    at kernel/qobject.cpp:3028
#15 0x4d7a447a in QMetaObject::activate (sender=<value optimized out>, 
    m=<value optimized out>, from_local_signal_index=<value optimized out>, 
    to_local_signal_index=<value optimized out>, argv=)
    at kernel/qobject.cpp:3118
#16 0x4e39385f in QAction::triggered (this=)
    at .moc/release-shared/moc_qaction.cpp:216
#17 0x4e394f3f in QAction::activate (this=<value optimized out>, 
    event=<value optimized out>) at kernel/qaction.cpp:1131
#18 0x4e680613 in QToolButton::nextCheckState (this=<value optimized out>)
    at ../../include/QtGui/../../src/gui/kernel/qaction.h:201
#19 0x4e5e3b17 in QAbstractButtonPrivate::click (this=<value optimized out>)
    at widgets/qabstractbutton.cpp:526
#20 0x4e5e3d56 in QAbstractButton::mouseReleaseEvent (
    this=<value optimized out>, e=<value optimized out>)
    at widgets/qabstractbutton.cpp:1116
#21 0x4e68147d in QToolButton::mouseReleaseEvent (this=)
    at widgets/qtoolbutton.cpp:677
#22 0x4e3d626b in QWidget::event (this=<value optimized out>, 
    event=<value optimized out>) at kernel/qwidget.cpp:7169
#23 0x4e5e2e38 in QAbstractButton::event (this=<value optimized out>, 
    e=<value optimized out>) at widgets/qabstractbutton.cpp:1078
#24 0x4e6805d7 in QToolButton::event (this=) at widgets/qtoolbutton.cpp:1109
#25 0x4e398a2c in QApplicationPrivate::notify_helper (
    this=<value optimized out>, receiver=<value optimized out>, 
    e=<value optimized out>) at kernel/qapplication.cpp:3809
#26 0x4e399abb in QApplication::notify (this=<value optimized out>, 
    receiver=<value optimized out>, e=<value optimized out>)
    at kernel/qapplication.cpp:3534
#27 0x4de458bd in KApplication::notify (this=<value optimized out>, 
    receiver=<value optimized out>, event=<value optimized out>)
    at /home/portage/tmp/portage/kde-base/kdelibs-4.1.2-r1/work/kdelibs-4.1.2/kdeui/kernel/kapplication.cpp:311
#28 0x4d796436 in QCoreApplication::notifyInternal (
    this=<value optimized out>, receiver=<value optimized out>, 
    event=<value optimized out>) at kernel/qcoreapplication.cpp:593
#29 0x4e3a0f62 in QCoreApplication::sendSpontaneousEvent (receiver=)
    at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:218
#30 0x4e39deb5 in QApplicationPrivate::sendMouseEvent (
    receiver=<value optimized out>, event=<value optimized out>, 
    alienWidget=<value optimized out>, nativeWidget=<value optimized out>, 
    buttonDown=<value optimized out>, lastMouseReceiver=<value optimized out>)
    at kernel/qapplication.cpp:2799
#31 0x4e3ec378 in QETWidget::translateMouseEvent (this=<value optimized out>, 
    event=<value optimized out>) at kernel/qapplication_x11.cpp:4048
#32 0x4e3eb0c8 in QApplication::x11ProcessEvent (this=<value optimized out>, 
    event=<value optimized out>) at kernel/qapplication_x11.cpp:3244
#33 0x4e406fec in QEventDispatcherX11::processEvents (
    this=<value optimized out>, flags=<value optimized out>)
    at kernel/qeventdispatcher_x11.cpp:134
#34 0x4d793f14 in QEventLoop::processEvents (this=<value optimized out>, 
    flags=<value optimized out>) at kernel/qeventloop.cpp:149
#35 0x4d7940b3 in QEventLoop::exec (this=<value optimized out>, 
    flags=<value optimized out>) at kernel/qeventloop.cpp:200
#36 0x4d796ab9 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:851
#37 0x4e3988d3 in QApplication::exec () at kernel/qapplication.cpp:3337
#38 0x0804dfee in main (argc=1309885280, argv=0x4e134360)
    at /home/portage/tmp/portage/kde-base/kig-4.1.2/work/kig-4.1.2/kig/kig/main.cpp:141
#39 0x4e0073f1 in __libc_start_main (main=) at libc-start.c:227
#40 0x0804d741 in _start ()
#0  0xffffe424 in __kernel_vsyscall ()

This is kig - a part of kde 4.1.2.
Comment 1 Peter Volkov 2008-10-23 19:19:53 UTC
Aha, this bug is reproducible. I have not set point, I've just started kig, closed "Do you know?" window, then chosed move parallel tool (at the left border top tool) set red dot on the workspace and then pressed close button, said that I don't want to save anything and got crash!
Comment 2 Pino Toscano 2008-10-27 20:46:34 UTC
Yes, I can confirm it.
I'll look at it ASAP, hopefully for KDE 4.1.3.
Comment 3 Dario Andres 2008-12-04 21:49:22 UTC
*** Bug 176157 has been marked as a duplicate of this bug. ***
Comment 4 Dario Andres 2009-01-17 23:14:23 UTC
*** Bug 180817 has been marked as a duplicate of this bug. ***
Comment 5 Dario Andres 2009-06-19 15:24:49 UTC
*** Bug 196947 has been marked as a duplicate of this bug. ***
Comment 6 Dario Andres 2009-09-28 02:07:10 UTC
*** Bug 184203 has been marked as a duplicate of this bug. ***
Comment 7 Dario Andres 2010-02-15 15:49:49 UTC
*** Bug 226722 has been marked as a duplicate of this bug. ***
Comment 8 Dario Andres 2010-02-15 15:50:16 UTC
*** Bug 212415 has been marked as a duplicate of this bug. ***
Comment 9 Matt 2010-03-30 22:09:04 UTC
Apparently, when I added several KDE packages to ubuntu, my system decided it is now ``kubuntu'', per the startup flash screen.  Now, the kde software does not all work.  HMM...
Comment 10 Christoph Feck 2010-09-13 17:14:19 UTC
Created attachment 51605 [details]
proposed patch

The bug is caused by ~KigPart being called while the nested event loop for the current mode is still running.

This patch works around that by disallowing the user to close the window while he is constructing something.
Comment 11 Christoph Feck 2011-02-24 13:40:39 UTC
*** Bug 267036 has been marked as a duplicate of this bug. ***
Comment 12 Ettore Atalan 2011-04-20 19:44:38 UTC
Created attachment 59165 [details]
New crash information added by DrKonqi

kig (v1.0) on KDE Platform 4.5.1 (KDE 4.5.1) using Qt 4.7.0

- What I was doing when the application crashed:

I started Kig for the first time, drawed some lines and tried out some buttons.
Lastly, I wanted to close Kig and did a click on X (close button), but the program didn't react and I clicked again and again on the close button until it crashed.

-- Backtrace (Reduced):
#6  QAction::setEnabled (this=0x10812e0, b=false) at kernel/qaction.cpp:1113
#7  0x00007f22dc8c9261 in KigMode::enableActions (this=0x109be60) at ../../kig/modes/mode.cc:30
#8  0x00007f22dc8cc98e in NormalMode::enableActions (this=0x10812e0) at ../../kig/modes/normal.cc:48
#9  0x00007f22dc90e151 in KigPart::setMode (this=0x1081920, m=0x0) at ../../kig/kig/kig_part.cpp:512
#10 0x00007f22dc90e33c in KigPart::runMode (this=0x1081920, m=0x130bb20) at ../../kig/kig/kig_part.cpp:678
Comment 13 David E. Narvaez 2012-05-26 11:55:29 UTC
This doesn't seem to be happening any more, so I'm closing this bug. Feel free to reopen if it appears again.
Comment 14 Christoph Feck 2012-05-26 22:21:55 UTC
The bug is still there. To reproduce:
- start kig
- klick on any construction tool in toolbar
- close window

Backtrace with today's master:

Application: Kig (kig), signal: Segmentation fault
[KCrash Handler]
#7  0xb60cdb00 in QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::data (this=0x45454549) at ../../include/QtCore/../../../../git/Qt/frameworks/qt/src/corelib/tools/qscopedpointer.h:135
#8  0xb60cca43 in qGetPtrHelper<QScopedPointer<QObjectData> > (p=...) at ../../include/QtCore/../../../../git/Qt/frameworks/qt/src/corelib/global/qglobal.h:2434
#9  0xb60ccf1a in QAction::d_func (this=0x45454545) at /local/git/Qt/frameworks/qt/src/gui/kernel/qaction.h:67
#10 0xb60cb67b in QAction::setEnabled (this=0x45454545, b=false) at /local/git/Qt/frameworks/qt/src/gui/kernel/qaction.cpp:1113
#11 0xb21aefcd in KigMode::enableActions (this=0x8748608) at /local/git/KDE/edu/kig/modes/mode.cc:30
#12 0xb21b35f2 in NormalMode::enableActions (this=0x8748608) at /local/git/KDE/edu/kig/modes/normal.cc:48
#13 0xb220b539 in KigPart::setMode (this=0x87577a8, m=0x8748608) at /local/git/KDE/edu/kig/kig/kig_part.cpp:518
#14 0xb220c256 in KigPart::runMode (this=0x87577a8, m=0x87549c8) at /local/git/KDE/edu/kig/kig/kig_part.cpp:696
#15 0xb216af9c in ConstructibleAction::act (this=0x87bc6a0, d=...) at /local/git/KDE/edu/kig/misc/guiaction.cc:80
#16 0xb216b352 in KigGUIAction::slotActivated (this=0x87f4c88) at /local/git/KDE/edu/kig/misc/guiaction.cc:106
#17 0xb216ac44 in KigGUIAction::qt_static_metacall (_o=0x87f4c88, _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0xbffcca88) at /local/build/KDE/edu/kig/guiaction.moc:49
#18 0xb5a38e0e in QMetaObject::activate (sender=0x87f4c88, m=0xb6bf37a8, local_signal_index=1, argv=0xbffcca88) at /local/git/Qt/frameworks/qt/src/corelib/kernel/qobject.cpp:3547
#19 0xb60cc92a in QAction::triggered (this=0x87f4c88, _t1=false) at .moc/debug-shared/moc_qaction.cpp:277
#20 0xb60cbd69 in QAction::activate (this=0x87f4c88, event=QAction::Trigger) at /local/git/Qt/frameworks/qt/src/gui/kernel/qaction.cpp:1257
#21 0xb60ccf89 in QAction::trigger (this=0x87f4c88) at /local/git/Qt/frameworks/qt/src/gui/kernel/qaction.h:218
#22 0xb6641887 in QToolButton::nextCheckState (this=0x8841798) at /local/git/Qt/frameworks/qt/src/gui/widgets/qtoolbutton.cpp:1144
#23 0xb6548c26 in QAbstractButtonPrivate::click (this=0x8841a78) at /local/git/Qt/frameworks/qt/src/gui/widgets/qabstractbutton.cpp:530
#24 0xb654a0a7 in QAbstractButton::mouseReleaseEvent (this=0x8841798, e=0xbffcd324) at /local/git/Qt/frameworks/qt/src/gui/widgets/qabstractbutton.cpp:1123
#25 0xb66401c6 in QToolButton::mouseReleaseEvent (this=0x8841798, e=0xbffcd324) at /local/git/Qt/frameworks/qt/src/gui/widgets/qtoolbutton.cpp:718
#26 0xb613b01d in QWidget::event (this=0x8841798, event=0xbffcd324) at /local/git/Qt/frameworks/qt/src/gui/kernel/qwidget.cpp:8371
#27 0xb6549f18 in QAbstractButton::event (this=0x8841798, e=0xbffcd324) at /local/git/Qt/frameworks/qt/src/gui/widgets/qabstractbutton.cpp:1082
#28 0xb66418fc in QToolButton::event (this=0x8841798, event=0xbffcd324) at /local/git/Qt/frameworks/qt/src/gui/widgets/qtoolbutton.cpp:1160
#29 0xb60db280 in QApplicationPrivate::notify_helper (this=0x861b2a8, receiver=0x8841798, e=0xbffcd324) at /local/git/Qt/frameworks/qt/src/gui/kernel/qapplication.cpp:4551
#30 0xb60d93b1 in QApplication::notify (this=0xbffcdac4, receiver=0x8841798, e=0xbffcd324) at /local/git/Qt/frameworks/qt/src/gui/kernel/qapplication.cpp:4094
#31 0xb6e21a3a in KApplication::notify (this=0xbffcdac4, receiver=0x8841798, event=0xbffcd324) at /local/git/KDE/libs/kdelibs/kdeui/kernel/kapplication.cpp:311
#32 0xb5a1d0a6 in QCoreApplication::notifyInternal (this=0xbffcdac4, receiver=0x8841798, event=0xbffcd324) at /local/git/Qt/frameworks/qt/src/corelib/kernel/qcoreapplication.cpp:915
#33 0xb60ddc63 in QCoreApplication::sendSpontaneousEvent (receiver=0x8841798, event=0xbffcd324) at ../../include/QtCore/../../../../git/Qt/frameworks/qt/src/corelib/kernel/qcoreapplication.h:234
#34 0xb60d7b35 in QApplicationPrivate::sendMouseEvent (receiver=0x8841798, event=0xbffcd324, alienWidget=0x8841798, nativeWidget=0x88405f8, buttonDown=0xb6c124e0, lastMouseReceiver=..., spontaneous=true) at /local/git/Qt/frameworks/qt/src/gui/kernel/qapplication.cpp:3160
#35 0xb6172ced in QETWidget::translateMouseEvent (this=0x88405f8, event=0xbffcd7f0) at /local/git/Qt/frameworks/qt/src/gui/kernel/qapplication_x11.cpp:4502
#36 0xb616f886 in QApplication::x11ProcessEvent (this=0xbffcdac4, event=0xbffcd7f0) at /local/git/Qt/frameworks/qt/src/gui/kernel/qapplication_x11.cpp:3503
#37 0xb61a6461 in x11EventSourceDispatch (s=0x861ae28, callback=0, user_data=0x0) at /local/git/Qt/frameworks/qt/src/gui/kernel/qguieventdispatcher_glib.cpp:146
#38 0xb4c0a863 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#39 0xb4c0ac00 in ?? () from /usr/lib/libglib-2.0.so.0
#40 0xb4c0ace1 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#41 0xb5a54cfe in QEventDispatcherGlib::processEvents (this=0x860ed10, flags=...) at /local/git/Qt/frameworks/qt/src/corelib/kernel/qeventdispatcher_glib.cpp:424
#42 0xb61a67b6 in QGuiEventDispatcherGlib::processEvents (this=0x860ed10, flags=...) at /local/git/Qt/frameworks/qt/src/gui/kernel/qguieventdispatcher_glib.cpp:204
#43 0xb5a1a755 in QEventLoop::processEvents (this=0xbffcda6c, flags=...) at /local/git/Qt/frameworks/qt/src/corelib/kernel/qeventloop.cpp:149
#44 0xb5a1a8cd in QEventLoop::exec (this=0xbffcda6c, flags=...) at /local/git/Qt/frameworks/qt/src/corelib/kernel/qeventloop.cpp:204
#45 0xb5a1d73c in QCoreApplication::exec () at /local/git/Qt/frameworks/qt/src/corelib/kernel/qcoreapplication.cpp:1187
#46 0xb60d8796 in QApplication::exec () at /local/git/Qt/frameworks/qt/src/gui/kernel/qapplication.cpp:3812
#47 0x0804ecca in main (argc=1, argv=0xbffcdc14) at /local/git/KDE/edu/kig/kig/main.cpp:141
Comment 15 David E. Narvaez 2012-05-27 04:43:01 UTC
Sorry, I totally misread the instructions in the bug report, indeed it is still reproducible. I'm taking a look at it. Thanks!
Comment 16 Christoph Feck 2013-03-12 18:09:45 UTC
*** Bug 316603 has been marked as a duplicate of this bug. ***
Comment 17 Jekyll Wu 2013-06-04 03:13:03 UTC
*** Bug 320665 has been marked as a duplicate of this bug. ***
Comment 18 Jacob Welsh 2014-02-01 16:38:28 UTC
Created attachment 84935 [details]
Proposed patch: cancel construction before quit

I can confirm Christoph's patch works as described, but I don't think it's a good user experience. You try to quit the program, and the button responds but it doesn't quit. There's no indication that the construct mode has to be canceled first.

Here's an update of the patch that escapes the nested event loop before quitting by canceling the construction. It's definitely an abuse of queryClose(), and I don't understand the Kig code well enough to guarantee it will always work. In particular, is it possible for there to be more than two levels of nested event loops, i.e. some other mode invoked from within a construct mode? Still, it does solve this particular crash, and makes the program behave as the user expects.

I don't see another way to do it, short of getting rid of the event loop nesting altogether, which seems to be the root of the problem. Although, a halfway but reliable alternative would be to cancel the construction but return false from KigPart::queryClose(). That is, the first time you try to quit, it just cancels the mode; the second time it really quits.
Comment 19 Christoph Feck 2014-02-09 21:25:33 UTC
Thanks Jacob, I tested your patch from https://git.reviewboard.kde.org/r/115604/ and it seems a far better workaround than mine :)
Comment 20 David E. Narvaez 2014-02-10 03:58:53 UTC
Jacob, thanks for the patch. I am currently racing against deadlines but I will try to look at it in the next couple of days, yet in general my preferred solution would be a patch that eliminates the event loop nesting (because trying to exit the nested loops correctly is apparently impossible or at least I haven't found a way to do so), have you considered that option?
Comment 21 Jacob Welsh 2014-02-10 04:41:12 UTC
Oh, I agree. I'd like to see the UI be more modeless in general, and flattening the event loop would be a prerequisite for that. But that looked like a bigger job than I care to bite off right now. So consider this a band-aid for a highly user-visible bug, in lieu of a grand rewrite that might never get done.
Comment 22 Albert Astals Cid 2014-02-13 21:55:43 UTC
Git commit a8d1873368c5872b388b20f4e3a9f23bf7b57b12 by Albert Astals Cid, on behalf of Jacob Welsh.
Committed on 13/02/2014 at 21:54.
Pushed by aacid into branch 'KDE/4.12'.

Fix memory corruption on quit by canceling the active construct mode

Acked by David Narváez
FIXED-IN: 4.12.3
REVIEW: 115604

M  +1    -19   kig/kig.cpp
M  +13   -0    kig/kig_part.cpp
M  +7    -0    kig/kig_part.h
M  +1    -1    modes/mode.cc

http://commits.kde.org/kig/a8d1873368c5872b388b20f4e3a9f23bf7b57b12