Summary: | CodeCompletionModel does not honor QAIM invariants [asserts in ~QPersistentModelIndex] | ||
---|---|---|---|
Product: | [Applications] kate | Reporter: | Keith Rusler <xzekecomax> |
Component: | part | Assignee: | KWrite Developers <kwrite-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | crash | CC: | afiestas, christoph, kfunk, mail, stupor_scurvy343, Thomas.Eschenbacher |
Priority: | HI | ||
Version: | Git | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/kate/a0a1b3ced5bdfe6c43a323ab7b700c20f1f4b93c | Version Fixed In: | 4.13 |
Sentry Crash Report: | |||
Attachments: | New crash information added by DrKonqi |
Description
Keith Rusler
2010-05-09 07:38:51 UTC
Either a bug in kate or qt, re-assigning to kate for now maybe they've seen this already before. This is very similar to bug #194111, instead of addRow here we have removeRow... The code completion model looks corrupted, guess this is a result of incorrect use while filling in in kdevelop. Never seen such crash with single-threaded kate word completion, therefor assigning back. can someone reproduce this? Created attachment 57614 [details]
New crash information added by DrKonqi
kdevelop (4.2.60) on KDE Platform 4.6.00 (4.6.0) using Qt 4.7.1
used kdev for some hours, triggered code completion => crash
-- Backtrace (Reduced):
#11 0x00007f951f093e67 in qt_assert_x (where=0x7f951f2c2e30 "QPersistentModelIndex::~QPersistentModelIndex", what=0x7f951f2c2e08 "persistent model indexes corrupted", file=0x7f951f2c2d7e "kernel/qabstractitemmodel.cpp", line=544) at global/qglobal.cpp:2035
#12 0x00007f951f1c3bf6 in QAbstractItemModelPrivate::removePersistentIndexData (this=0x62127d0, data=0x84edc80) at kernel/qabstractitemmodel.cpp:544
#13 0x00007f951f1c2b46 in QPersistentModelIndexData::destroy (data=0x84edc80) at kernel/qabstractitemmodel.cpp:83
#14 0x00007f951f1c2d69 in QPersistentModelIndex::~QPersistentModelIndex (this=0x43af500, __in_chrg=<value optimized out>) at kernel/qabstractitemmodel.cpp:155
#15 0x00007f951e711621 in QItemSelectionRange::~QItemSelectionRange (this=0x43af500, __in_chrg=<value optimized out>) at ../../include/QtGui/../../src/gui/itemviews/qitemselectionmodel.h:59
Just experienced the same, using KDevelop/KDevplatform/Kate from Git master. Backtrace: (gdb) bt #0 0x00007ffff47ddf77 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 #1 0x00007ffff47e15e8 in __GI_abort () at abort.c:90 #2 0x00007ffff5dca40b in qt_message_output (msgType=QtFatalMsg, buf=0x6796328 "ASSERT failure in QPersistentModelIndex::~QPersistentModelIndex: \"persistent model indexes corrupted\", file /home/krf/devel/src/qt/src/corelib/kernel/qabstractitemmodel.cpp, line 544") at / home/krf/devel/src/qt/src/corelib/global/qglobal.cpp:2323 #3 0x00007ffff5dca5aa in qt_message(QtMsgType, const char *, typedef __va_list_tag __va_list_tag *) (msgType=QtFatalMsg, msg=0x7ffff5fb5628 "ASSERT failure in %s: \"%s\", file %s, line %d", ap=0x7fffffffb528) at /home/krf/devel/src/qt/src/corelib/global/qglobal.cpp:2369 #4 0x00007ffff5dcad74 in qFatal (msg=0x7ffff5fb5628 "ASSERT failure in %s: \"%s\", file %s, line %d") at /home/krf/devel/src/qt/src/corelib/global/qglobal.cpp:2552 #5 0x00007ffff5dca003 in qt_assert_x (where=0x7ffff6036c78 "QPersistentModelIndex::~QPersistentModelIndex", what=0x7ffff6036c50 "persistent model indexes corrupted", file=0x7ffff6036ba0 "/home/krf/devel/src/qt/src/corelib/kernel/qabstractitemmodel.cpp", line=544) at /ho me/krf/devel/src/qt/src/corelib/global/qglobal.cpp:2026 #6 0x00007ffff5f02f52 in QAbstractItemModelPrivate::removePersistentIndexData (this=0x440fcb0, data=0x66d2610) at /home/krf/devel/src/qt/src/corelib/kernel/qabstractitemmodel.cpp:543 #7 0x00007ffff5f01fea in QPersistentModelIndexData::destroy (data=0x66d2610) at /home/krf/devel/src/qt/src/corelib/kernel/qabstractitemmodel.cpp:83 #8 0x00007ffff5f02107 in QPersistentModelIndex::~QPersistentModelIndex (this=0x7fffffffb700, __in_chrg=<optimized out>) at /home/krf/devel/src/qt/src/corelib/kernel/qabstractitemmodel.cpp:155 #9 0x00007ffff582e2c6 in QItemSelectionModel::setCurrentIndex (this=0x444b750, index=..., command=...) at /home/krf/devel/src/qt/src/gui/itemviews/qitemselectionmodel.cpp:1181 #10 0x00007ffff57bd02d in QAbstractItemView::setCurrentIndex (this=0x4410100, index=...) at /home/krf/devel/src/qt/src/gui/itemviews/qabstractitemview.cpp:1022 #11 0x00007fff59b3bd49 in KateCompletionWidget::modelContentChanged (this=0x440f840) at /home/krf/devel/src/kate/part/completion/katecompletionwidget.cpp:222 #12 0x00007ffff5f31f23 in QMetaObject::activate (sender=0x440fbe0, m=0x7fff59f6e7e0 <KateCompletionModel::staticMetaObject>, local_signal_index=2, argv=0x0) at /home/krf/devel/src/qt/src/corelib/kernel/qobject.cpp:3547 #13 0x00007fff59b41373 in KateCompletionModel::contentGeometryChanged (this=this@entry=0x440fbe0) at /home/krf/devel/build/kate/part/katecompletionmodel.moc:146 #14 0x00007fff59b45f88 in KateCompletionModel::resort (this=this@entry=0x440fbe0) at /home/krf/devel/src/kate/part/completion/katecompletionmodel.cpp:1593 #15 0x00007fff59b46460 in KateCompletionModel::setCurrentCompletion (this=0x440fbe0, model=0x3de66d0, completion="view.setSource(") at /home/krf/devel/src/kate/part/completion/katecompletionmodel.cpp:957 #16 0x00007fff59b3ca7f in KateCompletionWidget::cursorPositionChanged (this=0x440f840) at /home/krf/devel/src/kate/part/completion/katecompletionwidget.cpp:727 #17 0x00007ffff5f31f23 in QMetaObject::activate (sender=0x41e5590, m=0x7ffff737fa00 <KTextEditor::View::staticMetaObject>, local_signal_index=7, argv=0x7fffffffbd40) at /home/krf/devel/src/qt/src/corelib/kernel/qobject.cpp:3547 #18 0x00007ffff715c4a7 in KTextEditor::View::cursorPositionChanged (this=<optimized out>, _t1=0x41e5590, _t2=[11, 19]) at /home/krf/devel/build/kdelibs/interfaces/ktexteditor/view.moc:187 #19 0x00007fff59bfa6ed in KateViewInternal::updateCursor (this=this@entry=0x435d5a0, newCursor=[11, 19], force=force@entry=true, center=center@entry=false, calledExternally=calledExternally@entry=false) at /home/krf/devel/src/kate/part/view/kateviewinternal.cpp:1899 #20 0x00007fff59bfecd7 in KateViewInternal::editEnd (this=0x435d5a0, editTagLineStart=11, editTagLineEnd=editTagLineEnd@entry=11, tagFrom=tagFrom@entry=false) at /home/krf/devel/src/kate/part/view/kateviewinternal.cpp:3365 #21 0x00007fff59be55ff in KateView::editEnd (this=this@entry=0x41e5590, editTagLineStart=<optimized out>, editTagLineEnd=editTagLineEnd@entry=11, tagFrom=tagFrom@entry=false) at /home/krf/devel/src/kate/part/view/kateview.cpp:1843 #22 0x00007fff59b800c4 in KateDocument::editEnd (this=this@entry=0x418e120) at /home/krf/devel/src/kate/part/document/katedocument.cpp:821 #23 0x00007fff59b82dc1 in KateDocument::removeText (this=this@entry=0x418e120, _range=[ (11, 19) -> (11, 20) ], block=block@entry=false) at /home/krf/devel/src/kate/part/document/katedocument.cpp:697 #24 0x00007fff59b831e9 in KateDocument::backspace (this=0x418e120, view=view@entry=0x41e5590, c=[11, 20]) at /home/krf/devel/src/kate/part/document/katedocument.cpp:2776 #25 0x00007fff59bf4432 in KateViewInternal::doBackspace (this=<optimized out>) at /home/krf/devel/src/kate/part/view/kateviewinternal.cpp:799 (gdb) #26 0x00007ffff5f31f23 in QMetaObject::activate (sender=0x44088a0, m=0x7ffff5cd9760 <QAction::staticMetaObject>, local_signal_index=1, argv=0x7fffffffc1f0) at /home/krf/devel/src/qt/src/corelib/kernel/qobject.cpp:3547 #27 0x00007ffff50e753a in QAction::triggered (this=0x44088a0, _t1=false) at .moc/debug-shared/moc_qaction.cpp:276 #28 0x00007ffff50e6902 in QAction::activate (this=0x44088a0, event=QAction::Trigger) at /home/krf/devel/src/qt/src/gui/kernel/qaction.cpp:1257 #29 0x00007ffff50e6664 in QAction::event (this=0x44088a0, e=0x7fffffffc7d0) at /home/krf/devel/src/qt/src/gui/kernel/qaction.cpp:1183 #30 0x00007ffff624ed3b in KAction::event (this=0x44088a0, event=0x7fffffffc7d0) at /home/krf/devel/src/kdelibs/kdeui/actions/kaction.cpp:131 #31 0x00007ffff50f73a0 in QApplicationPrivate::notify_helper (this=0x6d2840, receiver=0x44088a0, e=0x7fffffffc7d0) at /home/krf/devel/src/qt/src/gui/kernel/qapplication.cpp:4562 #32 0x00007ffff50f4713 in QApplication::notify (this=0x7fffffffd9e0, receiver=0x44088a0, e=0x7fffffffc7d0) at /home/krf/devel/src/qt/src/gui/kernel/qapplication.cpp:3944 #33 0x00007ffff6311db6 in KApplication::notify (this=0x7fffffffd9e0, receiver=0x44088a0, event=0x7fffffffc7d0) at /home/krf/devel/src/kdelibs/kdeui/kernel/kapplication.cpp:311 #34 0x00007ffff5f134c4 in QCoreApplication::notifyInternal (this=0x7fffffffd9e0, receiver=0x44088a0, event=0x7fffffffc7d0) at /home/krf/devel/src/qt/src/corelib/kernel/qcoreapplication.cpp:949 #35 0x00007ffff6ddf523 in QCoreApplication::sendEvent (receiver=0x44088a0, event=0x7fffffffc7d0) at ../../include/QtCore/../../../../src/qt/src/corelib/kernel/qcoreapplication.h:231 #36 0x00007ffff5137e65 in QShortcutMap::dispatchEvent (this=0x6d2960, e=0x7fffffffcd70) at /home/krf/devel/src/qt/src/gui/kernel/qshortcutmap.cpp:884 #37 0x00007ffff51364bf in QShortcutMap::tryShortcutEvent (this=0x6d2960, o=0x435d5a0, e=0x7fffffffcd70) at /home/krf/devel/src/qt/src/gui/kernel/qshortcutmap.cpp:364 #38 0x00007ffff50f49c6 in QApplication::notify (this=0x7fffffffd9e0, receiver=0x435d5a0, e=0x7fffffffcd70) at /home/krf/devel/src/qt/src/gui/kernel/qapplication.cpp:3986 #39 0x00007ffff6311db6 in KApplication::notify (this=0x7fffffffd9e0, receiver=0x435d5a0, event=0x7fffffffcd70) at /home/krf/devel/src/kdelibs/kdeui/kernel/kapplication.cpp:311 #40 0x00007ffff5f134c4 in QCoreApplication::notifyInternal (this=0x7fffffffd9e0, receiver=0x435d5a0, event=0x7fffffffcd70) at /home/krf/devel/src/qt/src/corelib/kernel/qcoreapplication.cpp:949 #41 0x00007ffff50fa7c9 in QCoreApplication::sendSpontaneousEvent (receiver=0x435d5a0, event=0x7fffffffcd70) at ../../include/QtCore/../../../../src/qt/src/corelib/kernel/qcoreapplication.h:234 #42 0x00007ffff50f76f3 in qt_sendSpontaneousEvent (receiver=0x435d5a0, event=0x7fffffffcd70) at /home/krf/devel/src/qt/src/gui/kernel/qapplication.cpp:5560 #43 0x00007ffff51d0547 in QKeyMapper::sendKeyEvent (keyWidget=0x435d5a0, grab=false, type=QEvent::KeyPress, code=16777219, modifiers=..., text="\b", autorepeat=false, count=1, nativeScanCode=22, nativeVirtualKey=65288, nativeModifiers=16) at /home/krf/devel/src/qt/src/gu i/kernel/qkeymapper_x11.cpp:1869 #44 0x00007ffff51d0211 in QKeyMapperPrivate::translateKeyEvent (this=0x731c70, keyWidget=0x435d5a0, event=0x7fffffffd510, grab=false) at /home/krf/devel/src/qt/src/gui/kernel/qkeymapper_x11.cpp:1839 #45 0x00007ffff5195e41 in QApplication::x11ProcessEvent (this=0x7fffffffd9e0, event=0x7fffffffd510) at /home/krf/devel/src/qt/src/gui/kernel/qapplication_x11.cpp:3533 #46 0x00007ffff51d24f2 in x11EventSourceDispatch (s=0x6d5970, callback=0x0, user_data=0x0) at /home/krf/devel/src/qt/src/gui/kernel/qguieventdispatcher_glib.cpp:146 #47 0x00007fffef31c3b6 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #48 0x00007fffef31c708 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #49 0x00007fffef31c7ac in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0 #50 0x00007ffff5f4fecd in QEventDispatcherGlib::processEvents (this=0x6d5340, flags=...) at /home/krf/devel/src/qt/src/corelib/kernel/qeventdispatcher_glib.cpp:425 #51 0x00007ffff51d28ba in QGuiEventDispatcherGlib::processEvents (this=0x6d5340, flags=...) at /home/krf/devel/src/qt/src/gui/kernel/qguieventdispatcher_glib.cpp:204 #52 0x00007ffff5f1081c in QEventLoop::processEvents (this=0x7fffffffd880, flags=...) at /home/krf/devel/src/qt/src/corelib/kernel/qeventloop.cpp:149 #53 0x00007ffff5f109b0 in QEventLoop::exec (this=0x7fffffffd880, flags=...) at /home/krf/devel/src/qt/src/corelib/kernel/qeventloop.cpp:204 #54 0x00007ffff5f13b5a in QCoreApplication::exec () at /home/krf/devel/src/qt/src/corelib/kernel/qcoreapplication.cpp:1221 #55 0x00007ffff50f42fa in QApplication::exec () at /home/krf/devel/src/qt/src/gui/kernel/qapplication.cpp:3823 #56 0x000000000040f345 in main (argc=<optimized out>, argv=<optimized out>) at /home/krf/devel/src/kdevelop/app/main.cpp:559 Found a code snippet where this is easily triggered: """ void* foo() { return 0; }; int main() { void* v = foo(); } """ Put the cursor after 'foo' inside main. Then invoke the completion pop-up (Ctrl+Space), then press Backspace three times => Crash. I'm hitting this quite often, raising importance. kdevelop(28183)/Kate KateCompletionModel::parent: Couldn't find parent for index QModelIndex(0,0,0x436d590,KateCompletionModel(0x436e840) ) the kate completion model should be fixed by running it with a ModelTest hooked up Cannot reproduce in KWrite. @Milian, Kevin: If you can reproduce, can you investigate + provide a patch? Yeah of course you cannot reproduce in KWrite, you need fancy code completion which so far only KDevelop provides afaik. I reassigned this only to kate since it's the completion model there which is broken. We are the consumers and do feel responsible :) Question is when we find the time to rewrite / fixup the code completion model... I'm on it. The fix is relatively simple: Avoid using reset() inside KateCompletionModel. KateCompletionWidget is trying to call QAIM::setCurrentIndex during a model reset (i.e. when model indices got invalid without having notified QAIM about it). I have a local patch where I used {begin,end}ResetModel instead with a couple of cleanups which apparently fixes this crash. I'm testing it for a while to make sure it's not causing regressions. *** Bug 329047 has been marked as a duplicate of this bug. *** Git commit b768749230872b5acf0e2816dd855409f6d70733 by Kevin Funk. Committed on 11/12/2013 at 23:51. Pushed by kfunk into branch 'master'. Fix assert in ~QPersistentModelIndex KateCompletionWidget may call QAIM::setCurrentIndex during a reset of the model, inside KateCompletionWidget::modelContentChanged(). At this point, model indices are invalid, but QAIM wasn't informed about it. The main problem is that KateCompletionModel doesn't use the (relatively) new {begin,end}ResetModel blocks to make persistent model indices invalid when we start resetting the model. Instead reset() is used *after* we have reset the model. However, KateCompletionModel may emit contentGeometryChanged too early (before a reset()) and hence triggering QAIM::setCurrentIndex while QAIM is still referencing now invalid persistent model indices. Other changes: Remove contentGeometryChanged. Instead, use layoutChanged() and modelReset() signals to react to model changes. This also ports KateCompletionModel away from deprecated QAIM methods such as QAIM::reset() REVIEW: 113917 FIXED-IN: 4.13 M +38 -36 part/completion/katecompletionmodel.cpp M +5 -4 part/completion/katecompletionmodel.h M +4 -2 part/completion/katecompletionwidget.cpp http://commits.kde.org/kate/b768749230872b5acf0e2816dd855409f6d70733 Git commit a0a1b3ced5bdfe6c43a323ab7b700c20f1f4b93c by Michal Humpula, on behalf of Kevin Funk. Committed on 11/12/2013 at 23:51. Pushed by michalhumpula into branch 'frameworks'. Fix assert in ~QPersistentModelIndex KateCompletionWidget may call QAIM::setCurrentIndex during a reset of the model, inside KateCompletionWidget::modelContentChanged(). At this point, model indices are invalid, but QAIM wasn't informed about it. The main problem is that KateCompletionModel doesn't use the (relatively) new {begin,end}ResetModel blocks to make persistent model indices invalid when we start resetting the model. Instead reset() is used *after* we have reset the model. However, KateCompletionModel may emit contentGeometryChanged too early (before a reset()) and hence triggering QAIM::setCurrentIndex while QAIM is still referencing now invalid persistent model indices. Other changes: Remove contentGeometryChanged. Instead, use layoutChanged() and modelReset() signals to react to model changes. This also ports KateCompletionModel away from deprecated QAIM methods such as QAIM::reset() REVIEW: 113917 FIXED-IN: 4.13 M +38 -36 part/completion/katecompletionmodel.cpp M +5 -4 part/completion/katecompletionmodel.h M +4 -2 part/completion/katecompletionwidget.cpp http://commits.kde.org/kate/a0a1b3ced5bdfe6c43a323ab7b700c20f1f4b93c *** Bug 331503 has been marked as a duplicate of this bug. *** Is this a candidate for backporting to KDE/4.12? I'd leave this up to the Kate maintainers -- for me the patch worked fine, so i'm fine backporting it if needed. |