Created attachment 108651 [details] stack trace After commit 9ec89cdc6a1f6ef2548d318f97a908d17a2440b0 kdevelop crashes after opening a project containing some javascript files. Reverting that specific commit gets rid of the crashes and seems to have no bad side effects. Attached is a stack trace.
Created attachment 108652 [details] example crashing project Attached a project tarball. Containing only one 9-line javascript file. It alone has been able to crash kdevelop without failure.
I cannot confirm. Did you try clearing the cache?
Post stacktrace of crashing thread inline for SEO: Thread 1 (Thread 0x7ff8b5152080 (LWP 17102)): [KCrash Handler] #6 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 #7 0x00007ff8d9690c1a in __GI_abort () at abort.c:89 #8 0x00007ff8d9e9db0f in qt_message_fatal (context=..., message=<synthetic pointer>...) at global/qlogging.cpp:1690 #9 QMessageLogger::fatal (this=this@entry=0x7ffc4d24efe0, msg=msg@entry=0x7ff8da11a7d0 "ASSERT: \"%s\" in file %s, line %d") at global/qlogging.cpp:796 #10 0x00007ff8d9e966d6 in qt_assert (assertion=assertion@entry=0x7ff8da124cc2 "!d->ref.isShared()", file=file@entry=0x7ff8da124cb2 "tools/qlist.cpp", line=line@entry=139) at global/qglobal.cpp:3077 #11 0x00007ff8d9f00e39 in QListData::realloc (this=this@entry=0x7ffc4d24f0b0, alloc=alloc@entry=2) at tools/qlist.cpp:139 #12 0x00007ff8770d8315 in QList<QString>::reserve (alloc=2, this=0x7ffc4d24f0b0) at /usr/include/qt5/QtCore/qlist.h:574 #13 QList<QString>::QList (args=..., this=0x7ffc4d24f0b0) at /usr/include/qt5/QtCore/qlist.h:165 #14 QStringList::QStringList (args=..., this=0x7ffc4d24f0b0) at /usr/include/qt5/QtCore/qstringlist.h:112 #15 GccLikeCompiler::includes (this=0x2ba29c0, type=<optimized out>, arguments=...) at /usr/src/debug/dev-util/kdevelop-9999/kdevelop-9999/plugins/custom-definesandincludes/compilerprovider/gcclikecompiler.cpp:142 #16 0x00007ff8770c98cd in CompilerProvider::includes (this=<optimized out>, item=<optimized out>) at /usr/src/debug/dev-util/kdevelop-9999/kdevelop-9999/plugins/custom-definesandincludes/compilerprovider/compilerprovider.cpp:155 #17 0x00007ff8770a8fd4 in DefinesAndIncludesManager::includes (this=0x2b829e0, item=0x382a430, type=KDevelop::IDefinesAndIncludesManager::All) at /usr/src/debug/dev-util/kdevelop-9999/kdevelop-9999/plugins/custom-definesandincludes/definesandincludesmanager.cpp:203 #18 0x00007ff8741c8f34 in QmlJsParseJob::QmlJsParseJob (this=<optimized out>, url=..., languageSupport=<optimized out>) at /usr/src/debug/dev-util/kdevelop-9999/kdevelop-9999/plugins/qmljs/qmljsparsejob.cpp:86 #19 0x00007ff8741cfa86 in KDevQmlJsPlugin::createParseJob (this=0x5071450, url=...) at /usr/src/debug/dev-util/kdevelop-9999/kdevelop-9999/plugins/qmljs/kdevqmljsplugin.cpp:93 #20 0x00007ff8d785e35a in KDevelop::BackgroundParserPrivate::createParseJob (this=this@entry=0xe1d5b0, url=..., parsePlan=...) at /usr/src/debug/dev-util/kdevelop-9999/kdevelop-9999/kdevplatform/language/backgroundparser/backgroundparser.cpp:367 #21 0x00007ff8d786119b in KDevelop::BackgroundParserPrivate::parseDocumentsInternal (this=0xe1d5b0) at /usr/src/debug/dev-util/kdevelop-9999/kdevelop-9999/kdevplatform/language/backgroundparser/backgroundparser.cpp:308 #22 0x00007ff8d785aeb4 in KDevelop::BackgroundParser::parseDocuments (this=0xe1d580) at /usr/src/debug/dev-util/kdevelop-9999/kdevelop-9999/kdevplatform/language/backgroundparser/backgroundparser.cpp:657 #23 0x00007ff8d79efae5 in KDevelop::BackgroundParser::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at /usr/src/debug/dev-util/kdevelop-9999/kdevelop-9999_build/kdevplatform/language/KDevPlatformLanguage_autogen/7BZAXZBZPZ/moc_backgroundparser.cpp:249
I can't reproduce either, but I can see how this fails: #15 GccLikeCompiler::includes (this=0x2ba29c0, type=<optimized out>, arguments=...) at /usr/src/debug/dev-util/kdevelop-9999/kdevelop-9999/plugins/custom-definesandincludes/compilerprovider/gcclikecompiler.cpp:142 => calls ::languageOption(type=Utils::Other) which runs into the default-case in the switch statement, not returning a value => crash.
I think we need to restrict to project-specific and user-defined includes in the constructor QmlJsParseJob::QmlJsParseJob. So replace IDefinesAndIncludesManager::manager()->includes(...) by IDefinesAndIncludesManager::manager()->includes(..., IDefinesAndIncludesManager::ProjectSpecific | IDefinesAndIncludesManager::UserDefined) The compiler-specific includes only make sense if we actually have a compiler backend that can provide them. (Right now ICompiler is implemented by NoCompiler, GccLikeCompiler, and MsvcCompiler - so no compiler for QML JS here.)
Another solution would be to ignore files of type `Utils::Other` in CompilerProvider::includes/defines. The entire design is a bit problematic, because the QmlJS plugin asks the DefinesAndIncludesManager for include directories, but that manager is somehow tied to the idea of using the configured compiler (GCC/Clang/MSVC) to provide additional includes and defines. However, the configured compiler is obviously only used for C/C++ and similar languages, not QmlJS. Before this change, the standard include directories for GCC/Clang (/usr/include and so on) were used to parse QmlJS files, which I guess is not intended. (Or is it?)
Possible fixes: https://phabricator.kde.org/D8653, https://phabricator.kde.org/D8654. I tested both on the attached project, and there is no more crash with either one. Neither is particularly beautiful, but that's because the DefinesAndIncludesManager is mostly designed around C++ with other languages as afterthought. There is probably a better solution, but that needs more time.
The issue should now be fixed in master. Please check that it works for you.
Thank you for working on this. If the fix is confirmed, can you cherry-pick the change into the 5.2 branch so we get this in 5.2.1?
Seems to be fixed. I haven't been able to crash kdevelop today after updating to latest master.
I think this has been fixed, but I can't close the bug. Maybe someone with the appropriate permissions could do that.
Do you know if this is also fixed in the 5.1 branch? Thanks for the feedback!
The crash came with some Q_UNREACHABLE()s I added, and only after 5.1 was released. The only problem (if any) on 5.1 is that the C++ compiler's include directories are passed to the QmlJS parser, but that didn't seem to lead to any problems. There should be no crash though.