Bug 282118 - Crash on project load
Summary: Crash on project load
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Build tools: CMake (show other bugs)
Version: 4.2.60
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: 4.2.3
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-16 04:49 UTC by Felix Tiede
Modified: 2012-11-15 02:59 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
assert on null item importing (3.04 KB, patch)
2011-09-16 14:44 UTC, Aleix Pol
Details
New crash information added by DrKonqi (6.47 KB, text/plain)
2011-09-16 15:11 UTC, Felix Tiede
Details
New crash information added by DrKonqi (12.72 KB, text/plain)
2011-09-19 19:46 UTC, Felix Tiede
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Tiede 2011-09-16 04:49:02 UTC
Application: kdevelop (4.2.60)
KDE Platform Version: 4.7.1 (4.7.1) (Compiled from sources)
Qt Version: 4.7.4
Operating System: Linux 2.6.38-tuxonice-r2 x86_64
Distribution (Platform): Gentoo Packages

-- Information about the crash:
- What I was doing when the application crashed:
I started an existing session of kdevelop and got this crash.
I started a new session and tried to load a cmake-based project and got the same crash.

KDevPlatform is at commit 612aedb2e5ca72ea38eaaedcf9208898a032b05f
KDevelop is at commit 9af0925ebad9fef7aab997a90a85070fed8c3da9

The crash can be reproduced every time.

-- Backtrace:
Application: KDevelop (kdevelop), signal: Segmentation fault
[Current thread is 1 (Thread 0x7f3cb9623760 (LWP 32631))]

Thread 6 (Thread 0x7f3ca3d29700 (LWP 32632)):
#0  0x00007f3cb64c32eb in pthread_cond_timedwait () from /lib64/libpthread.so.0
#1  0x00007f3cb7a69f9e in QWaitCondition::wait(QMutex*, unsigned long) () from /usr/lib64/qt4/libQtCore.so.4
#2  0x00007f3cb3e1e565 in KDevelop::DUChainPrivate::CleanupThread::run (this=0x34a3310) at /var/tmp/portage/dev-util/kdevplatform-9999/work/kdevplatform-9999/language/duchain/duchain.cpp:282
#3  0x00007f3cb7a694e1 in ?? () from /usr/lib64/qt4/libQtCore.so.4
#4  0x00007f3cb64bea6d in start_thread () from /lib64/libpthread.so.0
#5  0x00007f3cb679dd7d in clone () from /lib64/libc.so.6

Thread 5 (Thread 0x7f3c90650700 (LWP 32640)):
#0  0x00007f3cb6795be7 in poll () from /lib64/libc.so.6
#1  0x00007f3cb126447a in ?? () from /usr/lib64/libglib-2.0.so.0
#2  0x00007f3cb12647d5 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#3  0x00007f3cb7b8243a in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt4/libQtCore.so.4
#4  0x00007f3cb7b57102 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt4/libQtCore.so.4
#5  0x00007f3cb7b57461 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt4/libQtCore.so.4
#6  0x00007f3cb7a66556 in QThread::exec() () from /usr/lib64/qt4/libQtCore.so.4
#7  0x00007f3cb7b373aa in ?? () from /usr/lib64/qt4/libQtCore.so.4
#8  0x00007f3cb7a694e1 in ?? () from /usr/lib64/qt4/libQtCore.so.4
#9  0x00007f3cb64bea6d in start_thread () from /lib64/libpthread.so.0
#10 0x00007f3cb679dd7d in clone () from /lib64/libc.so.6

Thread 4 (Thread 0x7f3c8f441700 (LWP 32662)):
#0  0x00007f3cb64c2f6c in pthread_cond_wait () from /lib64/libpthread.so.0
#1  0x00007f3cae607b34 in ?? () from /usr/lib64/qt4/libQtWebKit.so.4
#2  0x00007f3cae607c2f in ?? () from /usr/lib64/qt4/libQtWebKit.so.4
#3  0x00007f3cb64bea6d in start_thread () from /lib64/libpthread.so.0
#4  0x00007f3cb679dd7d in clone () from /lib64/libc.so.6

Thread 3 (Thread 0x7f3c8d43d700 (LWP 32663)):
#0  0x00007f3cb125e50e in g_main_context_query () from /usr/lib64/libglib-2.0.so.0
#1  0x00007f3cb12641d7 in ?? () from /usr/lib64/libglib-2.0.so.0
#2  0x00007f3cb12647d5 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#3  0x00007f3cb7b8243a in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt4/libQtCore.so.4
#4  0x00007f3cb7b57102 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt4/libQtCore.so.4
#5  0x00007f3cb7b57461 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt4/libQtCore.so.4
#6  0x00007f3cb7a66556 in QThread::exec() () from /usr/lib64/qt4/libQtCore.so.4
#7  0x00007f3cb7a694e1 in ?? () from /usr/lib64/qt4/libQtCore.so.4
#8  0x00007f3cb64bea6d in start_thread () from /lib64/libpthread.so.0
#9  0x00007f3cb679dd7d in clone () from /lib64/libc.so.6

Thread 2 (Thread 0x7f3c8e43f700 (LWP 595)):
[KCrash Handler]
#6  KDevelop::ProjectBaseItem::d_func (this=0x0) at /var/tmp/portage/dev-util/kdevplatform-9999/work/kdevplatform-9999/project/projectmodel.h:218
#7  0x00007f3cb4423d26 in KDevelop::ProjectBaseItem::url (this=0x0) at /var/tmp/portage/dev-util/kdevplatform-9999/work/kdevplatform-9999/project/projectmodel.cpp:425
#8  0x00007f3c8c5f4ac0 in CMakeManager::parse (this=<value optimized out>, item=<value optimized out>) at /var/tmp/portage/dev-util/kdevelop-9999/work/kdevelop-9999/projectmanagers/cmake/cmakemanager.cpp:671
#9  0x00007f3cb442ad92 in KDevelop::ImportProjectJobPrivate::import (this=0x55e3b40, folder=0x7f3cb6a29e01) at /var/tmp/portage/dev-util/kdevplatform-9999/work/kdevplatform-9999/project/importprojectjob.cpp:53
#10 0x00007f3cb442ac0c in QtConcurrent::RunFunctionTask<void>::run (this=0x561fa30) at /usr/include/qt4/QtCore/qtconcurrentrunbase.h:120
#11 0x00007f3cb7a5e556 in ?? () from /usr/lib64/qt4/libQtCore.so.4
#12 0x00007f3cb7a694e1 in ?? () from /usr/lib64/qt4/libQtCore.so.4
#13 0x00007f3cb64bea6d in start_thread () from /lib64/libpthread.so.0
#14 0x00007f3cb679dd7d in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7f3cb9623760 (LWP 32631)):
#0  0x00007f3cb6795be7 in poll () from /lib64/libc.so.6
#1  0x00007f3cad3d7a9f in ?? () from /usr/lib64/libxcb.so.1
#2  0x00007f3cad3d7ff8 in ?? () from /usr/lib64/libxcb.so.1
#3  0x00007f3cad3d823e in xcb_writev () from /usr/lib64/libxcb.so.1
#4  0x00007f3cb2b0b002 in _XSend () from /usr/lib64/libX11.so.6
#5  0x00007f3cb2b0b959 in _XEventsQueued () from /usr/lib64/libX11.so.6
#6  0x00007f3cb2afa978 in XEventsQueued () from /usr/lib64/libX11.so.6
#7  0x00007f3cb6fab8b2 in ?? () from /usr/lib64/qt4/libQtGui.so.4
#8  0x00007f3cb125fff4 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#9  0x00007f3cb12645d7 in ?? () from /usr/lib64/libglib-2.0.so.0
#10 0x00007f3cb12647d5 in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#11 0x00007f3cb7b82402 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt4/libQtCore.so.4
#12 0x00007f3cb6fab386 in ?? () from /usr/lib64/qt4/libQtGui.so.4
#13 0x00007f3cb7b57102 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt4/libQtCore.so.4
#14 0x00007f3cb7b57461 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib64/qt4/libQtCore.so.4
#15 0x00007f3cb7b5b267 in QCoreApplication::exec() () from /usr/lib64/qt4/libQtCore.so.4
#16 0x00000000004095a7 in main (argc=<value optimized out>, argv=<value optimized out>) at /var/tmp/portage/dev-util/kdevelop-9999/work/kdevelop-9999/app/main.cpp:474

Possible duplicates by query: bug 262206.

Reported using DrKonqi
Comment 1 Aleix Pol 2011-09-16 14:44:02 UTC
Created attachment 63699 [details]
assert on null item importing

Can you please try this patch for kdevplatform and tell me if it crashes differently with this?
Comment 2 Felix Tiede 2011-09-16 15:11:38 UTC
Created attachment 63703 [details]
New crash information added by DrKonqi

kdevelop (4.2.60) on KDE Platform 4.7.1 (4.7.1) using Qt 4.7.4

- What I was doing when the application crashed:
Opening a cmake-based project. I hope this trace (with the patch applied) helps.

-- Backtrace (Reduced):
#7  0x00007f4a76cbdd26 in KDevelop::ProjectBaseItem::url (this=0x0) at /var/tmp/portage/dev-util/kdevplatform-9999/work/kdevplatform-9999/project/projectmodel.cpp:425
#8  0x00007f4a4ade2ac0 in CMakeManager::parse (this=<value optimized out>, item=<value optimized out>) at /var/tmp/portage/dev-util/kdevelop-9999/work/kdevelop-9999/projectmanagers/cmake/cmakemanager.cpp:671
#9  0x00007f4a76cc4dfa in KDevelop::ImportProjectJobPrivate::import (this=0x490f220, folder=0x7f4a792c3e01) at /var/tmp/portage/dev-util/kdevplatform-9999/work/kdevplatform-9999/project/importprojectjob.cpp:53
#10 0x00007f4a76cc4c74 in QtConcurrent::RunFunctionTask<void>::run (this=0x20a9540) at /usr/include/qt4/QtCore/qtconcurrentrunbase.h:120
[...]
Comment 3 Felix Tiede 2011-09-17 06:31:26 UTC
I've did a little bisecting on both kdevplatform and kdevelop.

First I've bisected kdevplatform from 4ab36b4524ea2075fde54f50da94f8fc4c604520 (known good from earlier compile/usage) to 612aedb2e5ca72ea38eaaedcf9208898a032b05f (HEAD of master). Turned out kdevelop needed to be downgraded for this bisect operation so I've used kdevelop 99f57d0bff97571ad25f6a6ab6b02c9ed028ec8f as known good.

kdevplatform did not introduce this bug as kdevelop 99f57d0bff97571ad25f6a6ab6b02c9ed028ec8f works with all commits including HEAD.

Then I've bisected kdevelop from 99f57d0bff97571ad25f6a6ab6b02c9ed028ec8f (known good from above) to 7e781636ea0cde3600e36d907d9c2422b78b2239 (HEAD of master).
git bisect returned this result:
c369136bd76bb2bc4bc876558c78522fdc90a395 is the first bad commit
commit c369136bd76bb2bc4bc876558c78522fdc90a395
Author: Aleix Pol <aleixpol@kde.org>
Date:   Mon Sep 12 04:39:18 2011 +0200

    Export the cmakemodelitems in the cmake library.

:040000 040000 fd2c175c389c25d4cdada54478ff2eec39d01218 38c99f0f63c9f7b99ce87019942d62024dcec128 M	projectmanagers

I've verified again using kdevelop 264948cfa980a050972de6575f5ad2223449dad3 (commit immediately preceding c369136bd76bb2bc4bc876558c78522fdc90a395) and the bug did not occur.

I hope this helps :)
Comment 4 Aleix Pol 2011-09-19 10:16:19 UTC
Git commit 38c8eda64333c091e868dbc69a11207636227e52 by Aleix Pol.
Committed on 19/09/2011 at 12:14.
Pushed by apol into branch 'master'.

Get the URL from the item instead of from a dynamic_cast'ed item, just in case.

I'm hoping this will fix the problem in bug 282118, although I'm not sure why it's
being shown now.

BUG: 282118

M  +1    -1    projectmanagers/cmake/cmakemanager.cpp

http://commits.kde.org/kdevelop/38c8eda64333c091e868dbc69a11207636227e52
Comment 5 Felix Tiede 2011-09-19 19:46:27 UTC
Created attachment 63778 [details]
New crash information added by DrKonqi

kdevelop (4.2.60) on KDE Platform 4.7.1 (4.7.1) using Qt 4.7.4

Seems the crash has just been postponed now as it now happens just a little bit later but still on loading cmake-based projects.

-- Backtrace (Reduced):
#7  0x00007fee9ec6c9a7 in KDevelop::ProjectBaseItem::rowCount (this=0x0) at /var/tmp/portage/dev-util/kdevplatform-9999/work/kdevplatform-9999/project/projectmodel.cpp:261
#8  0x00007fee9ec6d794 in KDevelop::ProjectBaseItem::folderList (this=0x0) at /var/tmp/portage/dev-util/kdevplatform-9999/work/kdevplatform-9999/project/projectmodel.cpp:495
#9  0x00007fee7ea8e83a in CMakeFolderItem::cleanupBuildFolders (this=0x0, subs=<value optimized out>) at /var/tmp/portage/dev-util/kdevelop-9999/work/kdevelop-9999/projectmanagers/cmake/cmakemodelitems.cpp:104
#10 0x00007fee75a08fc5 in CMakeManager::parse (this=<value optimized out>, item=<value optimized out>) at /var/tmp/portage/dev-util/kdevelop-9999/work/kdevelop-9999/projectmanagers/cmake/cmakemanager.cpp:856
#11 0x00007fee9ec74d92 in KDevelop::ImportProjectJobPrivate::import (this=0x18d44c0, folder=0x3) at /var/tmp/portage/dev-util/kdevplatform-9999/work/kdevplatform-9999/project/importprojectjob.cpp:53
Comment 6 Ciprian Ciubotariu 2011-10-14 12:55:46 UTC
Judging by the commit that fixed it, the bug trackers were quick to judge its resolution as FIXED. The code below follows the main structure of CMakeManager::parse and demonstrates how a crash is certain if folder==NULL:

    CMakeFolderItem* folder = dynamic_cast<CMakeFolderItem*>( item );
    // ...
    if(folder && QFile::exists(cmakeListsPath.toLocalFile()))
    {
    // ...
    } else {
        folder->cleanupBuildFolders(QList<Subdirectory>());
        folder->cleanupTargets(QList<CMakeTarget>());
    }
    reloadFiles(folder);

From my short investigation I deduced the following:

- reloadFiles can be called on the in-parameter item
- the whole if-else can be moved above to protect the else branch if folder==NULL as well
- there are other functions in CMakeManager that attempt to use a folder dynamic_casted from a ProjectBaseItem without checking for NULL (CMakeManager::includeDirectories and CMakeManager::defines. For completeness, CMakeManager::defines is so certain the item will dynamic_cast to a CMakeFolderItem it doesn't even bother to check if the item got past the top item)

With these fixed I can only get the root folder to be parsed as a CMakeFolderItem, and all subfolders get parsed as normal folders (even though they contain a CMakeFiles.txt)

As a result, I believe a quick hacky fix should make sure ProjectBaseItems are always CMakeFolderItem objects.

I have been able to reproduce this on 2 out of 3 computers, one with 4 cores and another with 8 cores. The only computer where this works has 2 cores.

The last commit that I have tried and works on all computers is e9885bbf833429e2fc2b0206ff5cee6370c6287b.
Comment 7 Aleix Pol 2011-10-14 13:30:08 UTC
I'm marking as UNCONFIRMED since I don't have the time to look through it right now. Feel free to provide a patch or I'll look into it when I can.

Thanks for taking your time!
Comment 8 Andreas Pakulat 2011-10-14 15:00:38 UTC
The deduction that commit c369136bd76bb2bc4bc876558c78522fdc90a395 introduces this sounds wrong, if that commit makes a difference it would hint at a binary incompatibility i.e. the build and installation directories haven't been deleted during the bisecting. The only thing that changed in that commit is moving classes from one shared lib to another which is a bic change.

I don't understand the code thats been pointed out enough though to see where a ProjectFolderItem could be incorrectly cast into a CMakeModelItem and be added to the folderList. But the code between line 729 and 742 should be inspected I think.
Comment 9 Ciprian Ciubotariu 2011-10-14 16:33:08 UTC
I have done additional tracking on what other differences are between the working and the computers where kdevelop fails. From my perspective the crash appears from a compiler bug. Here are the facts:

- the 2-core working computer is gentoo amd64 (stable) with gcc 4.5.3
- the 8-core failing is gentoo amd64 (stable) with gcc 4.4.5
- the 4-core failing is ubuntu amd64 (lts) with gcc 4.4.3

I have switched to gcc-4.5.3 on the 8-core and kdevelop no longer crashes at startup.

Another interesting fact was while debugging the code mentioned above on the ubuntu 8-core was that before the dynamic_cast, the item variable was holding the valid pointer used when the import job was created. After stepping over the dynamic_cast, folder equaled NULL and GDB said on item that "value optimized out" (which, from my experience, is a red flag about misfires during build)

I think this is worth mentioning, and I am quite curious if anyone else can reproduce this behavior.
Comment 10 Ciprian Ciubotariu 2011-10-14 16:35:28 UTC
(In reply to comment #9)
> Another interesting fact was while debugging the code mentioned above on the
> ubuntu 8-core was that before the dynamic_cast, the item variable was holding
> the valid pointer used when the import job was created. After stepping over the
> dynamic_cast, folder equaled NULL and GDB said on item that "value optimized
> out" (which, from my experience, is a red flag about misfires during build)
> 

Let me rephrase that, since the way I've written before sucks.

I was debugging on the ubuntu 4-core computer. Before executing the dynamic_cast, gdb showed the proper value for the pointer in variable item. After stepping the instruction, item was "optimized out", which raised the question about a deeper issue.
Comment 11 Aleix Pol 2012-11-15 02:59:49 UTC
I think this was fixed, or at least I don't know of any reproductions of the problem.

Please reopen if that's not the case.