Bug 314213

Summary: Autocomplete resource [Python::PythonDeclarationCompletionItem::data]
Product: [Developer tools] kdev-python Reporter: Orlando Xavier <orlandoxavier.sh>
Component: Language supportAssignee: Sven Brauch <mail>
Status: REOPENED ---    
Severity: crash CC: abvit89, apaku, daniel, jonathan.verner
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: 1.4.0   
Platform: Mageia RPMs   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: A patch that seems to fix the crash
New crash information added by DrKonqi

Description Orlando Xavier 2013-01-31 21:31:50 UTC
Application: kdevelop (4.4.1)
KDE Platform Version: 4.9.97
Qt Version: 4.8.4
Operating System: Linux 3.8.0-desktop-0.rc4.1.mga3 x86_64
Distribution: "Mageia 3"

-- Information about the crash:
- What I was doing when the application crashed:

(en)
I was developing in Python, using the feature of autocomplete, and the KDevelop closed unexpectedly.

(pt_BR)
Eu estava desenvolvendo em Python, utilizando a funcionalidade de preenchimento automático, quando o KDevelop, inesperadamente, fechou.

The crash can be reproduced some of the time.

-- Backtrace:
Application: KDevelop (kdevelop), signal: Segmentation fault
Using host libthread_db library "/lib64/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f52e0042780 (LWP 16124))]

Thread 11 (Thread 0x7f52bc872700 (LWP 16126)):
#0  0x00007f52dc50d971 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f52ddaeeaa7 in QWaitCondition::wait(QMutex*, unsigned long) () from /lib64/libQtCore.so.4
#2  0x00007f52d9c48a2b in KDevelop::DUChainPrivate::CleanupThread::run() () from /lib64/libkdevplatformlanguage.so.6
#3  0x00007f52ddaee5ec in QThreadPrivate::start(void*) () from /lib64/libQtCore.so.4
#4  0x00007f52dc509d18 in start_thread () from /lib64/libpthread.so.0
#5  0x00007f52dc80d87d in clone () from /lib64/libc.so.6
#6  0x0000000000000000 in ?? ()

Thread 10 (Thread 0x7f52ae57b700 (LWP 16127)):
#0  0x00007f52d69e6514 in g_source_iter_next () from /lib64/libglib-2.0.so.0
#1  0x00007f52d69e81b7 in g_main_context_prepare () from /lib64/libglib-2.0.so.0
#2  0x00007f52d69e88cb in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
#3  0x00007f52d69e8ac4 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#4  0x00007f52ddc195e6 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#5  0x00007f52ddbe9f5f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#6  0x00007f52ddbea1e8 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#7  0x00007f52ddaeb610 in QThread::exec() () from /lib64/libQtCore.so.4
#8  0x00007f52ddaee5ec in QThreadPrivate::start(void*) () from /lib64/libQtCore.so.4
#9  0x00007f52dc509d18 in start_thread () from /lib64/libpthread.so.0
#10 0x00007f52dc80d87d in clone () from /lib64/libc.so.6
#11 0x0000000000000000 in ?? ()

Thread 9 (Thread 0x7f52a530b700 (LWP 16130)):
#0  0x00007f52dc50bbc0 in pthread_mutex_lock () from /lib64/libpthread.so.0
#1  0x00007f52d6a259d1 in g_mutex_lock () from /lib64/libglib-2.0.so.0
#2  0x00007f52d69e83ba in g_main_context_check () from /lib64/libglib-2.0.so.0
#3  0x00007f52d69e8942 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
#4  0x00007f52d69e8ac4 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#5  0x00007f52ddc195e6 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#6  0x00007f52ddbe9f5f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#7  0x00007f52ddbea1e8 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#8  0x00007f52ddaeb610 in QThread::exec() () from /lib64/libQtCore.so.4
#9  0x00007f52ddaee5ec in QThreadPrivate::start(void*) () from /lib64/libQtCore.so.4
#10 0x00007f52dc509d18 in start_thread () from /lib64/libpthread.so.0
#11 0x00007f52dc80d87d in clone () from /lib64/libc.so.6
#12 0x0000000000000000 in ?? ()

Thread 8 (Thread 0x7f52a4ac6700 (LWP 16134)):
#0  0x00007f52dc50d5c4 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f52d8fbe207 in QTWTF::TCMalloc_PageHeap::scavengerThread() () from /lib64/libQtScript.so.4
#2  0x00007f52d8fbe239 in QTWTF::TCMalloc_PageHeap::runScavengerThread(void*) () from /lib64/libQtScript.so.4
#3  0x00007f52dc509d18 in start_thread () from /lib64/libpthread.so.0
#4  0x00007f52dc80d87d in clone () from /lib64/libc.so.6
#5  0x0000000000000000 in ?? ()

Thread 7 (Thread 0x7f521acbf700 (LWP 16153)):
#0  0x00007fffaf5fead7 in clock_gettime ()
#1  0x00007f52dc820a6d in clock_gettime () from /lib64/libc.so.6
#2  0x00007f52ddb44524 in qt_gettime() () from /lib64/libQtCore.so.4
#3  0x00007f52ddc19eed in QTimerInfoList::updateCurrentTime() () from /lib64/libQtCore.so.4
#4  0x00007f52ddc1a233 in QTimerInfoList::timerWait(timeval&) () from /lib64/libQtCore.so.4
#5  0x00007f52ddc18c9c in timerSourcePrepareHelper(GTimerSource*, int*) () from /lib64/libQtCore.so.4
#6  0x00007f52ddc18d45 in timerSourcePrepare(_GSource*, int*) () from /lib64/libQtCore.so.4
#7  0x00007f52d69e8238 in g_main_context_prepare () from /lib64/libglib-2.0.so.0
#8  0x00007f52d69e88cb in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
#9  0x00007f52d69e8ac4 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#10 0x00007f52ddc195e6 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#11 0x00007f52ddbe9f5f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#12 0x00007f52ddbea1e8 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#13 0x00007f52ddaeb610 in QThread::exec() () from /lib64/libQtCore.so.4
#14 0x00007f52ddbca7af in QInotifyFileSystemWatcherEngine::run() () from /lib64/libQtCore.so.4
#15 0x00007f52ddaee5ec in QThreadPrivate::start(void*) () from /lib64/libQtCore.so.4
#16 0x00007f52dc509d18 in start_thread () from /lib64/libpthread.so.0
#17 0x00007f52dc80d87d in clone () from /lib64/libc.so.6
#18 0x0000000000000000 in ?? ()

Thread 6 (Thread 0x7f5218f23700 (LWP 16235)):
#0  0x00007f52dc50d5c4 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f52d326c03d in ?? () from /lib64/libQtWebKit.so.4
#2  0x00007f52d326c149 in ?? () from /lib64/libQtWebKit.so.4
#3  0x00007f52dc509d18 in start_thread () from /lib64/libpthread.so.0
#4  0x00007f52dc80d87d in clone () from /lib64/libc.so.6
#5  0x0000000000000000 in ?? ()

Thread 5 (Thread 0x7f5213fff700 (LWP 16236)):
#0  0x00007f52dc81af10 in __libc_disable_asynccancel () from /lib64/libc.so.6
#1  0x00007f52dc7ff869 in read () from /lib64/libc.so.6
#2  0x00007f52d6a24d0f in g_wakeup_acknowledge () from /lib64/libglib-2.0.so.0
#3  0x00007f52d69e8534 in g_main_context_check () from /lib64/libglib-2.0.so.0
#4  0x00007f52d69e8942 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
#5  0x00007f52d69e8ac4 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#6  0x00007f52ddc195e6 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#7  0x00007f52ddbe9f5f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#8  0x00007f52ddbea1e8 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#9  0x00007f52ddaeb610 in QThread::exec() () from /lib64/libQtCore.so.4
#10 0x00007f52ddaee5ec in QThreadPrivate::start(void*) () from /lib64/libQtCore.so.4
#11 0x00007f52dc509d18 in start_thread () from /lib64/libpthread.so.0
#12 0x00007f52dc80d87d in clone () from /lib64/libc.so.6
#13 0x0000000000000000 in ?? ()

Thread 4 (Thread 0x7f52133ee700 (LWP 16237)):
#0  0x00007f52dc50d5c4 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f52ddaeeb4b in QWaitCondition::wait(QMutex*, unsigned long) () from /lib64/libQtCore.so.4
#2  0x00007f52d3c87d61 in ThreadWeaver::WeaverImpl::blockThreadUntilJobsAreBeingAssigned(ThreadWeaver::Thread*) () from /lib64/libthreadweaver.so.4
#3  0x00007f52d3c8a5ab in ThreadWeaver::WorkingHardState::applyForWork(ThreadWeaver::Thread*, ThreadWeaver::Job*) () from /lib64/libthreadweaver.so.4
#4  0x00007f52d3c8941f in ThreadWeaver::ThreadRunHelper::run(ThreadWeaver::WeaverImpl*, ThreadWeaver::Thread*) () from /lib64/libthreadweaver.so.4
#5  0x00007f52d3c894ab in ThreadWeaver::Thread::run() () from /lib64/libthreadweaver.so.4
#6  0x00007f52ddaee5ec in QThreadPrivate::start(void*) () from /lib64/libQtCore.so.4
#7  0x00007f52dc509d18 in start_thread () from /lib64/libpthread.so.0
#8  0x00007f52dc80d87d in clone () from /lib64/libc.so.6
#9  0x0000000000000000 in ?? ()

Thread 3 (Thread 0x7f5212bed700 (LWP 16376)):
#0  0x00007f52dc50d5c4 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f52ddaeeb4b in QWaitCondition::wait(QMutex*, unsigned long) () from /lib64/libQtCore.so.4
#2  0x00007f52d3c87d61 in ThreadWeaver::WeaverImpl::blockThreadUntilJobsAreBeingAssigned(ThreadWeaver::Thread*) () from /lib64/libthreadweaver.so.4
#3  0x00007f52d3c8a5ab in ThreadWeaver::WorkingHardState::applyForWork(ThreadWeaver::Thread*, ThreadWeaver::Job*) () from /lib64/libthreadweaver.so.4
#4  0x00007f52d3c8a5c4 in ThreadWeaver::WorkingHardState::applyForWork(ThreadWeaver::Thread*, ThreadWeaver::Job*) () from /lib64/libthreadweaver.so.4
#5  0x00007f52d3c8a5c4 in ThreadWeaver::WorkingHardState::applyForWork(ThreadWeaver::Thread*, ThreadWeaver::Job*) () from /lib64/libthreadweaver.so.4
#6  0x00007f52d3c8941f in ThreadWeaver::ThreadRunHelper::run(ThreadWeaver::WeaverImpl*, ThreadWeaver::Thread*) () from /lib64/libthreadweaver.so.4
#7  0x00007f52d3c894ab in ThreadWeaver::Thread::run() () from /lib64/libthreadweaver.so.4
#8  0x00007f52ddaee5ec in QThreadPrivate::start(void*) () from /lib64/libQtCore.so.4
#9  0x00007f52dc509d18 in start_thread () from /lib64/libpthread.so.0
#10 0x00007f52dc80d87d in clone () from /lib64/libc.so.6
#11 0x0000000000000000 in ?? ()

Thread 2 (Thread 0x7f52123ec700 (LWP 16377)):
#0  0x00007f52dc50d5c4 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f52ddaeeb4b in QWaitCondition::wait(QMutex*, unsigned long) () from /lib64/libQtCore.so.4
#2  0x00007f52d3c87d61 in ThreadWeaver::WeaverImpl::blockThreadUntilJobsAreBeingAssigned(ThreadWeaver::Thread*) () from /lib64/libthreadweaver.so.4
#3  0x00007f52d3c8a5ab in ThreadWeaver::WorkingHardState::applyForWork(ThreadWeaver::Thread*, ThreadWeaver::Job*) () from /lib64/libthreadweaver.so.4
#4  0x00007f52d3c8941f in ThreadWeaver::ThreadRunHelper::run(ThreadWeaver::WeaverImpl*, ThreadWeaver::Thread*) () from /lib64/libthreadweaver.so.4
#5  0x00007f52d3c894ab in ThreadWeaver::Thread::run() () from /lib64/libthreadweaver.so.4
#6  0x00007f52ddaee5ec in QThreadPrivate::start(void*) () from /lib64/libQtCore.so.4
#7  0x00007f52dc509d18 in start_thread () from /lib64/libpthread.so.0
#8  0x00007f52dc80d87d in clone () from /lib64/libc.so.6
#9  0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7f52e0042780 (LWP 16124)):
[KCrash Handler]
#5  0x00007f52a559f512 in Python::PythonDeclarationCompletionItem::data(QModelIndex const&, int, KDevelop::CodeCompletionModel const*) const () from /lib64/libkdev4pythoncompletion.so
#6  0x00007f52a559fd81 in Python::FunctionDeclarationCompletionItem::data(QModelIndex const&, int, KDevelop::CodeCompletionModel const*) const () from /lib64/libkdev4pythoncompletion.so
#7  0x00007f52d9d32d41 in KDevelop::CodeCompletionModel::data(QModelIndex const&, int) const () from /lib64/libkdevplatformlanguage.so.6
#8  0x00007f52bcbe6f55 in KateCompletionModel::contextMatchQuality(QPair<KTextEditor::CodeCompletionModel*, QModelIndex> const&) const () from /lib64/libkatepartinterfaces.so.4
#9  0x00007f52bcbeb3e3 in KateCompletionModel::updateBestMatches() () from /lib64/libkatepartinterfaces.so.4
#10 0x00007f52bcbec6f5 in KateCompletionModel::createGroups() () from /lib64/libkatepartinterfaces.so.4
#11 0x00007f52bcbec994 in KateCompletionModel::setCompletionModels(QList<KTextEditor::CodeCompletionModel*> const&) () from /lib64/libkatepartinterfaces.so.4
#12 0x00007f52bcbdec3b in KateCompletionWidget::startCompletion(KTextEditor::Range const&, QList<KTextEditor::CodeCompletionModel*> const&, KTextEditor::CodeCompletionModel::InvocationType) () from /lib64/libkatepartinterfaces.so.4
#13 0x00007f52bcbe0324 in KateCompletionWidget::startCompletion(KTextEditor::CodeCompletionModel::InvocationType, QList<KTextEditor::CodeCompletionModel*> const&) () from /lib64/libkatepartinterfaces.so.4
#14 0x00007f52bcbe059e in KateCompletionWidget::automaticInvocation() () from /lib64/libkatepartinterfaces.so.4
#15 0x00007f52ddc0062f in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /lib64/libQtCore.so.4
#16 0x00007f52ddbff93c in QObject::event(QEvent*) () from /lib64/libQtCore.so.4
#17 0x00007f52dcf9c30c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib64/libQtGui.so.4
#18 0x00007f52dcfa078a in QApplication::notify(QObject*, QEvent*) () from /lib64/libQtGui.so.4
#19 0x00007f52de408c46 in KApplication::notify(QObject*, QEvent*) () from /lib64/libkdeui.so.5
#20 0x00007f52ddbeb20e in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /lib64/libQtCore.so.4
#21 0x00007f52ddc1be32 in QTimerInfoList::activateTimers() () from /lib64/libQtCore.so.4
#22 0x00007f52ddc18f54 in timerSourceDispatch(_GSource*, int (*)(void*), void*) () from /lib64/libQtCore.so.4
#23 0x00007f52d69e86d5 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#24 0x00007f52d69e8a08 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
#25 0x00007f52d69e8ac4 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#26 0x00007f52ddc195c6 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#27 0x00007f52dd03c34e in QGuiEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtGui.so.4
#28 0x00007f52ddbe9f5f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#29 0x00007f52ddbea1e8 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQtCore.so.4
#30 0x00007f52ddbeefd8 in QCoreApplication::exec() () from /lib64/libQtCore.so.4
#31 0x000000000040e97c in main ()

Reported using DrKonqi
Comment 1 Kevin Funk 2013-02-01 22:27:39 UTC
Please install debug symbols for kdevelop/kdevplatform. I suspect the backtrace is useless as-is.
Comment 2 Sven Brauch 2013-02-02 00:01:37 UTC
That looks difficult to fux without being able to reproduce it myself. Can you describe in more detail what you were doing to make this happen? Especially, the file being edited and the location in the file being edited would be useful.

Greetings
Comment 3 Daniel Gan-Levi 2013-02-10 09:35:34 UTC
Created attachment 77084 [details]
A patch that seems to fix the crash

I've had the same crash, so I tried to debug this - I've rearranged the code a bit to debug it better, but that seemed to fix the crash - and I am yet to understand why. You can apply this patch as a workaround though...
Comment 4 Daniel Gan-Levi 2013-02-27 13:46:16 UTC
Please disregard the patch - by mistake I've made the comparison to be always true.
(In reply to comment #3)
> Created attachment 77084 [details]
> A patch that seems to fix the crash
> 
> I've had the same crash, so I tried to debug this - I've rearranged the code
> a bit to debug it better, but that seemed to fix the crash - and I am yet to
> understand why. You can apply this patch as a workaround though...
Comment 5 Sven Brauch 2013-02-27 14:53:12 UTC
Oh sorry, I totally overlooked that patch. Did you find out anything about how to reproduce (or even fix) the crash?
Comment 6 Daniel Gan-Levi 2013-02-27 15:50:13 UTC
I can reproduce the crash - it seems to happen when I try to enter some unknown identifier in a deeply nested list comprehension. I have a core dump, and I can debug the core file in kdevelop itself. The crash happens on this line in declaration.cpp:

            if ( model->completionContext()->duContext()->topContext() == declaration()->context()->topContext() ) {

When I split the 2 parts of the comparison, the crash does not reproduce, like this:

            TopDUContext* modelComplTopContext = model->completionContext()->duContext()->topContext();
            TopDUContext* declTopContext = declaration()->context()->topContext();
            if ( modelComplTopContext == declTopContext ) {


(In reply to comment #5)
> Oh sorry, I totally overlooked that patch. Did you find out anything about
> how to reproduce (or even fix) the crash?
Comment 7 Sven Brauch 2013-02-27 16:01:53 UTC
Hey,

if you could send me the file where the crash happens and tell me where to type what, I might be able to reproduce the crash. Could you do that?

Thanks,
Sven
Comment 8 Daniel Gan-Levi 2013-02-28 13:26:23 UTC
Unfortunately, I couldn't reproduce it on a simpler project.
But I looked at the core file again today and I think I know why it crashed:
The line it crashed on is this:

             if ( model->completionContext()->duContext()->topContext() == declaration()->context()->topContext() ) {

Now, looking at the variables from the core at this frame:

model->m_completionContext->d->m_duContext->d->d->m_base is 0x0

But this is what should be returned by
model->completionContext()->duContext()
So topContext() gets called next on NULL pointer.
Comment 9 Daniel Gan-Levi 2013-02-28 13:36:59 UTC
The code that it crashes on looks something like this:

   def _doSomething(self):
        _logger.info("doing something")
        runMultipleOperations([
            otherpkg.newFooOperation(self.bar)
                for thing in self.things.itervalues()])

If I start typing something after itervalues(), it becomes underscored in yellow and after a few more characters it crashes. Again, it only happens in my project, I couldn't reproduce it on something simpler.
Comment 10 Sven Brauch 2013-02-28 14:03:23 UTC
Hm. Can't reproduce it with that, as you said...
If you manage to construct an example which crashes this, let me know. Other than that... I'll think about it, maybe I can come up with something that fixes it. If not, I'll add a workardound for the next release, but I wouldn't like that. :(
Comment 11 Kevin Funk 2013-03-17 18:22:01 UTC
*** Bug 316925 has been marked as a duplicate of this bug. ***
Comment 12 Kevin Funk 2013-03-17 18:23:21 UTC
Reopening because of other duplicate bug report.

Pasting backtrace:
Thread 1 (Thread 0x7fbe8ccfd780 (LWP 7263)):
[KCrash Handler]
#6  0x00007fbe75808ea2 in Python::PythonDeclarationCompletionItem::data (this=0x7fbe70081630, index=..., role=<optimized out>, model=0x407db40) at /home/vitalii/kdev-python/codecompletion/items/declaration.cpp:73
#7  0x00007fbe75809711 in Python::FunctionDeclarationCompletionItem::data (this=0x7fbe70081630, index=..., role=34, model=0x407db40) at /home/vitalii/kdev-python/codecompletion/items/functiondeclaration.cpp:120
#8  0x00007fbe98865071 in KDevelop::CodeCompletionModel::data (this=0x407db40, index=..., role=34) at /home/vitalii/kdevplatform/language/codecompletion/codecompletionmodel.cpp:371
#9  0x00007fbe7e848645 in data (arole=34, this=0x7fff183db990) at /usr/include/QtCore/qabstractitemmodel.h:402
#10 KateCompletionModel::contextMatchQuality (this=0x5d1e0a0, source=...) at /usr/src/debug/kate-4.10.0/part/completion/katecompletionmodel.cpp:336
#11 0x00007fbe7e84ce0b in KateCompletionModel::updateBestMatches (this=this@entry=0x5d1e0a0) at /usr/src/debug/kate-4.10.0/part/completion/katecompletionmodel.cpp:2034
#12 0x00007fbe7e84d887 in KateCompletionModel::setCurrentCompletion (this=0x5d1e0a0, model=0x3c4a830, completion=...) at /usr/src/debug/kate-4.10.0/part/completion/katecompletionmodel.cpp:954
#13 0x00007fbe7e83fe1b in KateCompletionWidget::cursorPositionChanged (this=0x5d1dd00) at /usr/src/debug/kate-4.10.0/part/completion/katecompletionwidget.cpp:727
#14 0x00007fbe9c4251af in QMetaObject::activate (sender=0x5d936e0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff183dc0e0) at kernel/qobject.cpp:3548
#15 0x00007fbe9ee7eb67 in KTextEditor::View::cursorPositionChanged (this=<optimized out>, _t1=0x5d936e0, _t2=...) at /usr/src/debug/kdelibs-4.10.0/build/interfaces/ktexteditor/view.moc:188
#16 0x00007fbe7e9191fe in KateViewInternal::updateCursor (this=this@entry=0x5d93f20, newCursor=..., force=force@entry=true, center=center@entry=false, calledExternally=calledExternally@entry=false) at /usr/src/debug/kate-4.10.0/part/view/kateviewinternal.cpp:1910
#17 0x00007fbe7e91961f in KateViewInternal::editEnd (this=0x5d93f20, editTagLineStart=<optimized out>, editTagLineEnd=<optimized out>, tagFrom=<optimized out>) at /usr/src/debug/kate-4.10.0/part/view/kateviewinternal.cpp:3372
#18 0x00007fbe7e886242 in editEnd (this=0x4a300d0) at /usr/src/debug/kate-4.10.0/part/document/katedocument.cpp:822
#19 KateDocument::editEnd (this=0x4a300d0) at /usr/src/debug/kate-4.10.0/part/document/katedocument.cpp:797
#20 0x00007fbe7e8885a1 in KateDocument::typeChars (this=0x4a300d0, view=0x5d936e0, realChars=...) at /usr/src/debug/kate-4.10.0/part/document/katedocument.cpp:2599
#21 0x00007fbe7e91e9a8 in keyPressEvent (e=0x7fff183dca60, this=0x5d93f20) at /usr/src/debug/kate-4.10.0/part/view/kateviewinternal.cpp:2402
#22 KateViewInternal::keyPressEvent (this=0x5d93f20, e=0x7fff183dca60) at /usr/src/debug/kate-4.10.0/part/view/kateviewinternal.cpp:2248
#23 0x00007fbe7e9167cd in KateViewInternal::eventFilter (this=0x5d93f20, obj=0x5d93f20, e=0x7fff183dca60) at /usr/src/debug/kate-4.10.0/part/view/kateviewinternal.cpp:2200
#24 0x00007fbe9c40fe06 in QCoreApplicationPrivate::sendThroughObjectEventFilters (this=<optimized out>, receiver=0x5d93f20, event=0x7fff183dca60) at kernel/qcoreapplication.cpp:1056
#25 0x00007fbe9b59d83c in QApplicationPrivate::notify_helper (this=this@entry=0x20cf5a0, receiver=receiver@entry=0x5d93f20, e=e@entry=0x7fff183dca60) at kernel/qapplication.cpp:4558
#26 0x00007fbe9b5a2864 in QApplication::notify (this=<optimized out>, receiver=0x5d93f20, e=0x7fff183dca60) at kernel/qapplication.cpp:4003
#27 0x00007fbe9cc27cb6 in KApplication::notify (this=0x7fff183ddc30, receiver=0x5d93f20, event=0x7fff183dca60) at /usr/src/debug/kdelibs-4.10.0/kdeui/kernel/kapplication.cpp:311
#28 0x00007fbe9c40fc9e in QCoreApplication::notifyInternal (this=0x7fff183ddc30, receiver=0x5d93f20, event=0x7fff183dca60) at kernel/qcoreapplication.cpp:946
#29 0x00007fbe9b639e8a in QKeyMapper::sendKeyEvent (keyWidget=keyWidget@entry=0x5d93f20, grab=grab@entry=false, type=QEvent::KeyPress, code=82, modifiers=..., text=..., autorepeat=autorepeat@entry=false, count=1, nativeScanCode=27, nativeVirtualKey=114, nativeModifiers=16) at kernel/qkeymapper_x11.cpp:1866
#30 0x00007fbe9b63a2c1 in QKeyMapperPrivate::translateKeyEvent (this=0x211da20, keyWidget=0x5d93f20, event=0x7fff183dd480, grab=false) at kernel/qkeymapper_x11.cpp:1836
#31 0x00007fbe9b6179f8 in QApplication::x11ProcessEvent (this=0x7fff183ddc30, event=0x7fff183dd480) at kernel/qapplication_x11.cpp:3543
#32 0x00007fbe9b63dfa2 in x11EventSourceDispatch (s=0x20c7ef0, callback=0x0, user_data=0x0) at kernel/qguieventdispatcher_glib.cpp:146
#33 0x00007fbe947d17d5 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#34 0x00007fbe947d1b08 in ?? () from /usr/lib64/libglib-2.0.so.0
#35 0x00007fbe947d1bc4 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#36 0x00007fbe9c43e1d6 in QEventDispatcherGlib::processEvents (this=0x2034c70, flags=...) at kernel/qeventdispatcher_glib.cpp:424
#37 0x00007fbe9b63dc1e in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#38 0x00007fbe9c40e9ef in QEventLoop::processEvents (this=this@entry=0x7fff183dd850, flags=...) at kernel/qeventloop.cpp:149
#39 0x00007fbe9c40ec78 in QEventLoop::exec (this=0x7fff183dd850, flags=...) at kernel/qeventloop.cpp:204
#40 0x00007fbe9c413918 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1218
#41 0x000000000040e711 in main (argc=<optimized out>, argv=<optimized out>) at /home/vitalii/kdevelop/app/main.cpp:522
Comment 13 Andreas Pakulat 2013-04-07 22:21:49 UTC
Created attachment 78717 [details]
New crash information added by DrKonqi

kdevelop (4.5.60) on KDE Platform 4.8.4 (4.8.4) using Qt 4.8.2

- What I was doing when the application crashed:

Tried to open the code completion right after typing a few characters. Might have typed another one or two characters with completion open to limit the number of results, not 100% sure about the latter. Can't say wether a parse of the file was still in progress - I did change the scope of a function right before starting to type that functions name.

-- Backtrace (Reduced):
#7  0xe701989c in Python::PythonDeclarationCompletionItem::data (this=0xd828bde8, index=..., role=34, model=0x9d46de0) at /home/andreas/src/kdev-python/codecompletion/items/declaration.cpp:79
#8  0xe701a699 in Python::FunctionDeclarationCompletionItem::data (this=0xd828bde8, index=..., role=34, model=0x9d46de0) at /home/andreas/src/kdev-python/codecompletion/items/functiondeclaration.cpp:117
#9  0xf4bbaaae in KDevelop::CodeCompletionModel::data (this=0x9d46de0, index=..., role=34) at /home/andreas/src/kdevplatform/language/codecompletion/codecompletionmodel.cpp:371
#10 0xe8a24e8e in QModelIndex::data (this=0xffb69e1c, arole=34) at /usr/include/qt4/QtCore/qabstractitemmodel.h:402
#11 0xe8a28ede in KateCompletionModel::contextMatchQuality (this=0x9dec540, source=...) at /home/andreas/src/kate/part/completion/katecompletionmodel.cpp:336
Comment 14 Sven Brauch 2013-04-07 22:39:10 UTC
Git commit 01aa82dfbdff19295877729012becdb8615f0d7f by Sven Brauch.
Committed on 08/04/2013 at 00:38.
Pushed by brauch into branch '1.5'.

add an extra safety check in declaration completion item

might fix a crash, or not

M  +1    -0    codecompletion/items/declaration.cpp

http://commits.kde.org/kdev-python/01aa82dfbdff19295877729012becdb8615f0d7f
Comment 15 Sven Brauch 2013-04-07 23:52:06 UTC
Git commit f5353859631f1256112a618b2129c6be1e15ea85 by Sven Brauch.
Committed on 08/04/2013 at 00:38.
Pushed by brauch into branch 'master'.

add an extra safety check in declaration completion item

might fix a crash, or not

M  +1    -0    codecompletion/items/declaration.cpp

http://commits.kde.org/kdev-python/f5353859631f1256112a618b2129c6be1e15ea85
Comment 16 Sven Brauch 2013-05-02 17:17:05 UTC
Closing as fixed because nobody complained that it's not.
Comment 17 Jonathan Verner 2021-11-01 00:05:59 UTC
Hmm, I hit this crash again today.  The (relevant part of the) back-trace is as follows:

#0  Python::PythonDeclarationCompletionItem::data(QModelIndex const&, int, KDevelop::CodeCompletionModel const*) const
    (this=0x7ffed4ca3110, index=..., role=258, model=0x55555af291d0)
    at kdev-python/codecompletion/items/declaration.cpp:92
#1  in KDevelop::CodeCompletionModel::data(QModelIndex const&, int) const (this=0x55555af291d0, index=..., role=258)
    at kdevelop/kdevplatform/language/codecompletion/codecompletionmodel.cpp:378
#2  in KateCompletionModel::contextMatchQuality(QPair<KTextEditor::CodeCompletionModel*, QModelIndex> const&) const ()
    at /usr/lib/x86_64-linux-gnu/libKF5TextEditor.so.5

The code crashes because `model->completionContext()->duContext()` is null at that point (although non-nullness was
checked previously on line 79 of kdev-python/codecompletion/items/declaration.cpp, per the fix by @Sven in f5353859631f12561)

Probably a DUChainReader lock around the switch statement would help?