Bug 323212 - Crash when parsing qmake pro files that have variables in .qmake.conf
Summary: Crash when parsing qmake pro files that have variables in .qmake.conf
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Unclassified
Component: Build tools: QMake (show other bugs)
Version: 4.5.1
Platform: Compiled Sources Linux
: NOR crash (vote)
Target Milestone: 4.3.0
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-06 07:27 UTC by Cyrille Berger
Modified: 2013-09-20 17:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch that I use to avoid the crash (471 bytes, patch)
2013-08-06 07:28 UTC, Cyrille Berger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Cyrille Berger 2013-08-06 07:27:44 UTC
I have a .qmake.conf file (this a Qt5 qmake feature) with:
top_srcdir=$$PWD
top_builddir=$$shadowed($$PWD)

And a pri file with:
INCLUDEPATH += $$top_srcdir/
DEPENDPATH  += $$top_srcdir/

And I am assuming that ".qmake.conf" is not supported by kdev-qmake, meaning that kdev-qmake tries to add "/" to INCLUDEPATH, which leads to a crash in resolveShellGlobbingInternal (from qmakefile.cpp, see backtrace bellow), since the segments list is empty (because QString("/").split(QLatin1Char('/'), QString::SkipEmptyParts) returns an empty list).

Backtrace:
#0  0x00007ffff5cd834e in QString::indexOf (this=this@entry=0x61ce78 <QListData::shared_null+24>, ch=..., from=from@entry=0, 
    cs=cs@entry=Qt::CaseSensitive) at tools/qstring.cpp:2626
#1  0x00007fff2bdec9d1 in contains (cs=Qt::CaseSensitive, c=..., this=0x61ce78 <QListData::shared_null+24>)
    at /usr/include/qt4/QtCore/qstring.h:905
#2  resolveShellGlobbingInternal (segments=..., dir=..., offset=offset@entry=0)
    at /home/cyrille/Applications/kdevelop/kdev-qmake/qmakefile.cpp:45
#3  0x00007fff2bdecce4 in resolveShellGlobbingInternal (pattern=..., dir=...)
    at /home/cyrille/Applications/kdevelop/kdev-qmake/qmakefile.cpp:82
#4  0x00007fff2bdecd4a in QMakeFile::resolveShellGlobbing (this=this@entry=0x4766a20, pattern=...)
    at /home/cyrille/Applications/kdevelop/kdev-qmake/qmakefile.cpp:187
#5  0x00007fff2bdecda0 in resolveFileName (file=..., this=this@entry=0x4766a20)
    at /home/cyrille/Applications/kdevelop/kdev-qmake/qmakefile.cpp:201
#6  QMakeFile::resolveToSingleFileName (this=this@entry=0x4766a20, file=...)
    at /home/cyrille/Applications/kdevelop/kdev-qmake/qmakefile.cpp:192
#7  0x00007fff2bde6ff7 in QMakeProjectFile::addUrlsForVariable (this=this@entry=0x4766a20, variable=..., 
    list=list@entry=0x7fffffffc9a0) at /home/cyrille/Applications/kdevelop/kdev-qmake/qmakeprojectfile.cpp:166
#8  0x00007fff2bde7c53 in QMakeProjectFile::includeDirectories (this=this@entry=0x4766a20)
    at /home/cyrille/Applications/kdevelop/kdev-qmake/qmakeprojectfile.cpp:179
#9  0x00007fff2bddfedd in QMakeProjectManager::includeDirectories (this=<optimized out>, item=0x3dc5710)
    at /home/cyrille/Applications/kdevelop/kdev-qmake/qmakemanager.cpp:459
#10 0x00007fffc8b36ea6 in IncludePathComputer::computeForeground (this=this@entry=0x4b2ebe0)
    at ../../../languages/cpp/includepathcomputer.cpp:96
#11 0x00007fffc8b2f145 in CppLanguageSupport::findIncludePathsForJob (this=<optimized out>, job=0x4b92110)
    at ../../../languages/cpp/cpplanguagesupport.cpp:435
#12 0x00007ffff5da929e in QObject::event (this=0x2721650, e=<optimized out>) at kernel/qobject.cpp:1194
#13 0x00007ffff513d0ec in QApplicationPrivate::notify_helper (this=this@entry=0x6ed3a0, receiver=receiver@entry=0x2721650, 
    e=e@entry=0x7ffed8063300) at kernel/qapplication.cpp:4567
#14 0x00007ffff513fa5b in QApplication::notify (this=this@entry=0x7fffffffd970, receiver=receiver@entry=0x2721650, 
    e=e@entry=0x7ffed8063300) at kernel/qapplication.cpp:4428
#15 0x00007ffff6348516 in KApplication::notify (this=0x7fffffffd970, receiver=0x2721650, event=0x7ffed8063300)
    at ../../kdeui/kernel/kapplication.cpp:311
#16 0x00007ffff5d8f3ae in QCoreApplication::notifyInternal (this=0x7fffffffd970, receiver=receiver@entry=0x2721650, 
    event=event@entry=0x7ffed8063300) at kernel/qcoreapplication.cpp:946
#17 0x00007ffff5d92ee1 in sendEvent (event=0x7ffed8063300, receiver=0x2721650)
    at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#18 QCoreApplicationPrivate::sendPostedEvents (receiver=receiver@entry=0x0, event_type=event_type@entry=0, data=0x628510)
    at kernel/qcoreapplication.cpp:1570
#19 0x00007ffff5d93213 in QCoreApplication::sendPostedEvents (receiver=receiver@entry=0x0, event_type=event_type@entry=0)
    at kernel/qcoreapplication.cpp:1463
#20 0x00007ffff5dbdb53 in sendPostedEvents () at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:236
#21 postEventSourceDispatch (s=0x6ed860) at kernel/qeventdispatcher_glib.cpp:279
#22 0x00007fffeed7af25 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#23 0x00007fffeed7b268 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#24 0x00007fffeed7b324 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#25 0x00007ffff5dbdce6 in QEventDispatcherGlib::processEvents (this=0x6299d0, flags=...) at kernel/qeventdispatcher_glib.cpp:424
#26 0x00007ffff51def9e in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...)
    at kernel/qguieventdispatcher_glib.cpp:204
#27 0x00007ffff5d8e0ff in QEventLoop::processEvents (this=this@entry=0x7fffffffd590, flags=...) at kernel/qeventloop.cpp:149
#28 0x00007ffff5d8e388 in QEventLoop::exec (this=this@entry=0x7fffffffd590, flags=...) at kernel/qeventloop.cpp:204
#29 0x00007ffff5d93a66 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1218
#30 0x00007ffff513ba5c in QApplication::exec () at kernel/qapplication.cpp:3828
#31 0x000000000040dca1 in main (argc=<optimized out>, argv=<optimized out>) at ../../app/main.cpp:522


Reproducible: Always
Comment 1 Cyrille Berger 2013-08-06 07:28:55 UTC
Created attachment 81579 [details]
patch that I use to avoid the crash
Comment 2 Kevin Funk 2013-08-06 07:45:46 UTC
From a quick look at the code in qmakefile.cpp:
You're not building in debug mode, right? Because otherwise you should hit the assert at the beginning of the method: segments.size() == 0 && offset == 0 => assert triggered.

In that case the patch should rather be 'if (segments.size() <= offset) return QStringList();', no?

(Note: I'm not into the qmake codebase at all)
Comment 3 Milian Wolff 2013-08-06 10:11:37 UTC
Git commit f4e3694405e8d5c925aa565ebe7ff6636e5a40f6 by Milian Wolff.
Committed on 06/08/2013 at 10:10.
Pushed by mwolff into branch 'master'.

Don't crash when the pattern only consists of forward slashes.

In such cases, the exploded pattern will be empty as we skip
empty parts and split on '/'.

M  +3    -1    qmakefile.cpp

http://commits.kde.org/kdev-qmake/f4e3694405e8d5c925aa565ebe7ff6636e5a40f6