Bug 431811 - KDevelop crashes when parsing projects that use wxWidgets-3.1.4
Summary: KDevelop crashes when parsing projects that use wxWidgets-3.1.4
Status: RESOLVED DUPLICATE of bug 438249
Alias: None
Product: kdevelop
Classification: Applications
Component: general (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-19 07:55 UTC by kogiokkafrms
Modified: 2022-06-02 07:33 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
An wxWidgets example project for reproducing the bug (1.54 KB, application/zip)
2021-01-19 07:55 UTC, kogiokkafrms
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kogiokkafrms 2021-01-19 07:55:26 UTC
Created attachment 134991 [details]
An wxWidgets example project for reproducing the bug

SUMMARY

KDevelop crashes when parsing projects using wxWidgets-3.1.4, but has no issue with projects using wxWidgets-3.0.4. I'm not sure if there are any more libraries will cause this issue.

STEPS TO REPRODUCE

1. Get wxWidgets-3.1.4. I built the library from source.
2. Create CMake cache of the attachment project with "cmake -Bbuild -DCMAKE_PREFIX_PATH=<path-to-wxWidgets-3.1.4>"
3. Execute "kdevelop --ps" and Create New Session
4. Open Project and choose the attachment project
5. Before the parsing is finished, KDevelop will crash silently

OBSERVED RESULT

I did some tests and found out that it is caused by "clang_getFieldDeclBitWidth" in "plugins/clang/duchain/builder.cpp":

https://invent.kde.org/kdevelop/kdevelop/-/blob/e2595310efbd6ec5f9c3c1ce49b46d80b07aecb7/plugins/clang/duchain/builder.cpp#L1090

If I change
    decl->setBitWidth(clang_getFieldDeclBitWidth(cursor));
to
    decl->setBitWidth(-1);
, KDevelop will finish the parsing without issue. 


BACKTRACE

#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:498
#1  0x00007fff5e074c0b in llvm::APInt::APInt(llvm::APInt const&) (that=..., this=0x7fff5cab2600) at /usr/include/llvm/ADT/APInt.h:325
#2  llvm::APSInt::APSInt(llvm::APSInt const&) (this=0x7fff5cab2600) at /usr/include/llvm/ADT/APSInt.h:21
#3  clang::Expr::EvaluateKnownConstInt(clang::ASTContext const&, llvm::SmallVectorImpl<std::pair<clang::SourceLocation, clang::PartialDiagnostic> >*) const (this=0x7fff1b680f10, Ctx=..., Diag=Diag@entry=0x0) at ../lib/AST/ExprConstant.cpp:13991
#4  0x00007fff5dfe4736 in clang::FieldDecl::getBitWidthValue(clang::ASTContext const&) const (this=<optimized out>, Ctx=...) at ../include/clang/AST/Decl.h:2864
#5  0x00007fff69892a3a in (anonymous namespace)::Visitor::setDeclData<(CXCursorKind)6>(CXCursor, KDevelop::ClassMemberDeclaration*) (cursor=..., decl=decl@entry=0x7fff52a70720, this=0x7fff5cab53f0) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/cursorkindtraits.h:199
#6  0x00007fff6989fc66 in (anonymous namespace)::Visitor::createDeclarationCommon<(CXCursorKind)6, KDevelop::ClassMemberDeclaration>(CXCursor, KDevelop::Identifier const&) (this=this@entry=0x7fff5cab53f0, cursor=..., id=...) at /usr/include/c++/10/bits/atomic_base.h:333
#7  0x00007fff698b7209 in (anonymous namespace)::Visitor::createDeclaration<(CXCursorKind)6, KDevelop::ClassMemberDeclaration> (context=0x0, id=..., cursor=..., this=0x7fff5cab53f0) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:466
#8  (anonymous namespace)::Visitor::buildDeclaration<(CXCursorKind)6, KDevelop::ClassMemberDeclaration, false> (cursor=..., this=0x7fff5cab53f0) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:1224
#9  (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)6> (parent=..., cursor=..., this=0x7fff5cab53f0) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:991
#10 (anonymous namespace)::visitCursor(CXCursor, CXCursor, CXClientData) (cursor=..., parent=..., data=0x7fff5cab53f0) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:1561
#11 0x00007fff5df43a86 in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) (this=this@entry=0x7fff5cab2d10, Cursor=..., CheckedRegionOfInterest=CheckedRegionOfInterest@entry=true) at ../tools/libclang/CIndex.cpp:214
#12 0x00007fff5df4444d in clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl const*) (this=this@entry=0x7fff5cab2d10, D=0x7fff1b680f60) at ../tools/libclang/CIndex.cpp:676
#13 0x00007fff5df44648 in clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*) (this=0x7fff5cab2d10, DC=0x7fff1b680c98) at ../tools/libclang/CIndex.cpp:637
#14 0x00007fff5df435a7 in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) (this=0x7fff5cab2d10, Cursor=...) at ../tools/libclang/CIndex.cpp:507
#15 0x00007fff5df4b22d in clang_visitChildren(CXCursor, CXCursorVisitor, CXClientData) (parent=..., visitor=<optimized out>, client_data=<optimized out>) at ../tools/libclang/CIndex.cpp:4441
#16 0x00007fff698a24b3 in (anonymous namespace)::Visitor::buildDeclaration<(CXCursorKind)2, KDevelop::ClassDeclaration, true>(CXCursor) (this=0x7fff5cab53f0, cursor=...) at /usr/include/c++/10/bits/move.h:101
#17 0x00007fff698b8c88 in (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)2> (parent=..., cursor=..., this=0x7fff5cab53f0) at /home/luis/kde/src/kdevelop/kdevplatform/language/duchain/types/typepointer.h:39
#18 (anonymous namespace)::visitCursor(CXCursor, CXCursor, CXClientData) (cursor=..., parent=..., data=0x7fff5cab53f0) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:1557
#19 0x00007fff5df43a86 in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) (this=this@entry=0x7fff5cab3800, Cursor=..., CheckedRegionOfInterest=CheckedRegionOfInterest@entry=false) at ../tools/libclang/CIndex.cpp:214
#20 0x00007fff5df491b4 in clang::cxcursor::CursorVisitor::RunVisitorWorkList(llvm::SmallVector<clang::cxcursor::VisitorJob, 10u>&) (this=0x7fff5cab3800, WL=...) at ../tools/libclang/CIndex.cpp:3046
#21 0x00007fff5df4991b in clang::cxcursor::CursorVisitor::Visit(clang::Stmt const*) (this=this@entry=0x7fff5cab3800, S=0x7fff1b681180) at ../tools/libclang/CIndex.cpp:3248
#22 0x00007fff5df4356f in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) (this=0x7fff5cab3800, Cursor=...) at ../tools/libclang/CIndex.cpp:515
#23 0x00007fff5df4b22d in clang_visitChildren(CXCursor, CXCursorVisitor, CXClientData) (parent=..., visitor=<optimized out>, client_data=<optimized out>) at ../tools/libclang/CIndex.cpp:4441
#24 0x00007fff698b5cdd in (anonymous namespace)::Visitor::buildCompoundStatement<(CXCursorKind)144> (cursor=..., this=<optimized out>) at /usr/include/c++/10/bits/move.h:101
#25 (anonymous namespace)::visitCursor(CXCursor, CXCursor, CXClientData) (cursor=..., parent=..., data=0x7fff5cab53f0) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:1606
#26 0x00007fff5df43a86 in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) (this=this@entry=0x7fff5cab3f50, Cursor=..., CheckedRegionOfInterest=CheckedRegionOfInterest@entry=false) at ../tools/libclang/CIndex.cpp:214
#27 0x00007fff5df486a1 in clang::cxcursor::CursorVisitor::VisitFunctionDecl(clang::FunctionDecl*) (this=0x7fff5cab3f50, ND=0x7fff1b67ef78) at ../include/clang/AST/Decl.h:2059
#28 0x00007fff5df435a7 in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) (this=0x7fff5cab3f50, Cursor=...) at ../tools/libclang/CIndex.cpp:507
#29 0x00007fff5df4b22d in clang_visitChildren(CXCursor, CXCursorVisitor, CXClientData) (parent=..., visitor=<optimized out>, client_data=<optimized out>) at ../tools/libclang/CIndex.cpp:4441
#30 0x00007fff698a6f55 in (anonymous namespace)::Visitor::buildDeclaration<(CXCursorKind)30, KDevelop::ClassFunctionDeclaration, true>(CXCursor) (this=0x7fff5cab53f0, cursor=...) at /usr/include/c++/10/bits/move.h:101
#31 0x00007fff698b19fe in (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)30, (Decision)0, (Decision)1> (parent=..., cursor=..., this=<optimized out>) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:972
#32 (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)30, (Decision)0, (Decision)2> (parent=..., cursor=..., this=<optimized out>) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:967
#33 (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)30>(CXCursor, CXCursor) (this=<optimized out>, cursor=..., parent=...) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:954
#34 0x000000000000001e in  ()
#35 0x00007fff1b67f018 in  ()
#36 0x0000000000000001 in  ()
#37 0x00007fff18035f20 in  ()
#38 0x000000000000001f in  ()
#39 0x00007fff1b67d788 in  ()
#40 0x0000000000000001 in  ()
#41 0x00007fff18035f20 in  ()
#42 0x00007fff5cab53f0 in  ()
#43 0x00007fff5cab4480 in  ()
#44 0x00007fff5cab44a0 in  ()
#45 0x00007fff1b67da08 in  ()
#46 0x00007fff5cab4810 in  ()
#47 0x00007fff698b5d5f in (anonymous namespace)::visitCursor(CXCursor, CXCursor, CXClientData) (cursor=..., parent=..., data=0x0) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:1608
#48 0x000000000000001e in  ()
#49 0x00007fff1b67f018 in  ()
#50 0x00007fff5cab4810 in  ()
#51 0x00007fff5cab4640 in  ()
#52 0x00007fff5df4444d in clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl const*) (this=0x7fff1b67d788, this@entry=0x7fff5cab4810, D=0x1f) at ../tools/libclang/CIndex.cpp:676
#53 0x00007fff5df44648 in clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*) (this=0x7fff5cab4810, DC=0x7fff1b67d738) at ../tools/libclang/CIndex.cpp:637
#54 0x00007fff5df435a7 in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) (this=0x7fff5cab4810, Cursor=...) at ../tools/libclang/CIndex.cpp:507
#55 0x00007fff5df4b22d in clang_visitChildren(CXCursor, CXCursorVisitor, CXClientData) (parent=..., visitor=<optimized out>, client_data=<optimized out>) at ../tools/libclang/CIndex.cpp:4441
#56 0x00007fff698a8a05 in (anonymous namespace)::Visitor::buildDeclaration<(CXCursorKind)31, KDevelop::ClassDeclaration, true> (cursor=..., this=0x7fff5cab53f0) at /usr/include/c++/10/bits/move.h:101
#57 (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)31, (Decision)0, (Decision)0> (parent=..., cursor=..., this=0x7fff5cab53f0) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:991
#58 (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)31, (Decision)0, (Decision)2>(CXCursor, CXCursor) (this=0x7fff5cab53f0, cursor=..., parent=...) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:966
#59 0x00007fff698b8a0b in (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)31> (parent=..., cursor=..., this=0x7fff5cab53f0) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:701
#60 (anonymous namespace)::visitCursor(CXCursor, CXCursor, CXClientData) (cursor=..., parent=..., data=0x7fff5cab53f0) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:1577
#61 0x00007fff5df43a86 in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) (this=this@entry=0x7fff5cab50d0, Cursor=..., CheckedRegionOfInterest=CheckedRegionOfInterest@entry=true) at ../tools/libclang/CIndex.cpp:214
#62 0x00007fff5df4444d in clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl const*) (this=this@entry=0x7fff5cab50d0, D=0x7fff1b67d788) at ../tools/libclang/CIndex.cpp:676
#63 0x00007fff5df44648 in clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*) (this=0x7fff5cab50d0, DC=0x7fff180b6bd0) at ../tools/libclang/CIndex.cpp:637
#64 0x00007fff5df4386a in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) (this=0x7fff5cab50d0, Cursor=...) at ../include/clang/AST/ASTContext.h:1009
#65 0x00007fff5df4b22d in clang_visitChildren(CXCursor, CXCursorVisitor, CXClientData) (parent=..., visitor=<optimized out>, client_data=<optimized out>) at ../tools/libclang/CIndex.cpp:4441
#66 0x00007fff69898881 in (anonymous namespace)::Visitor::Visitor (update=false, includes=..., file=0x7fff1b64c150, tu=<optimized out>, this=0x7fff5cab53f0) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:1478
#67 Builder::visit(CXTranslationUnitImpl*, void*, QHash<void*, KDevelop::ReferencedTopDUContext> const&, bool) (tu=<optimized out>, file=file@entry=0x7fff1b64c150, includes=..., update=update@entry=false) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/builder.cpp:1625
#68 0x00007fff698c1e9d in ClangHelpers::buildDUChain(void*, QMultiHash<void*, Import> const&, ParseSession const&, QFlags<KDevelop::TopDUContext::Feature>, QHash<void*, KDevelop::ReferencedTopDUContext>&, QHash<KDevelop::IndexedString, KDevelop::ModificationRevision> const&, KDevelop::IndexedString const&, ClangIndex*, std::function<bool ()> const&) (file=<optimized out>, imports=..., session=..., features=..., includedFiles=..., unsavedRevisions=..., parseDocument=..., index=0x5a55a0, abortFunction=...) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/clanghelpers.cpp:221
#69 0x00007fff698c1800 in ClangHelpers::buildDUChain(void*, QMultiHash<void*, Import> const&, ParseSession const&, QFlags<KDevelop::TopDUContext::Feature>, QHash<void*, KDevelop::ReferencedTopDUContext>&, QHash<KDevelop::IndexedString, KDevelop::ModificationRevision> const&, KDevelop::IndexedString const&, ClangIndex*, std::function<bool ()> const&) (file=<optimized out>, imports=..., session=..., features=..., includedFiles=..., unsavedRevisions=..., parseDocument=..., index=0x5a55a0, abortFunction=...) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/clanghelpers.cpp:135
#70 0x00007fff698c1800 in ClangHelpers::buildDUChain(void*, QMultiHash<void*, Import> const&, ParseSession const&, QFlags<KDevelop::TopDUContext::Feature>, QHash<void*, KDevelop::ReferencedTopDUContext>&, QHash<KDevelop::IndexedString, KDevelop::ModificationRevision> const&, KDevelop::IndexedString const&, ClangIndex*, std::function<bool ()> const&) (file=<optimized out>, imports=..., session=..., features=..., includedFiles=..., unsavedRevisions=..., parseDocument=..., index=0x5a55a0, abortFunction=...) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/clanghelpers.cpp:135
#71 0x00007fff698c1800 in ClangHelpers::buildDUChain(void*, QMultiHash<void*, Import> const&, ParseSession const&, QFlags<KDevelop::TopDUContext::Feature>, QHash<void*, KDevelop::ReferencedTopDUContext>&, QHash<KDevelop::IndexedString, KDevelop::ModificationRevision> const&, KDevelop::IndexedString const&, ClangIndex*, std::function<bool ()> const&) (file=<optimized out>, imports=..., session=..., features=features@entry=..., includedFiles=..., unsavedRevisions=..., parseDocument=..., index=0x5a55a0, abortFunction=...) at /home/luis/kde/src/kdevelop/plugins/clang/duchain/clanghelpers.cpp:135
#72 0x00007fff699173ad in ClangParseJob::run(QSharedPointer<ThreadWeaver::JobInterface>, ThreadWeaver::Thread*) (this=<optimized out>) at /home/luis/kde/src/kdevelop/plugins/clang/clangparsejob.cpp:233
#73 0x00007ffff6de70eb in ThreadWeaver::IdDecorator::run(QSharedPointer<ThreadWeaver::JobInterface>, ThreadWeaver::Thread*) (this=<optimized out>, self=..., thread=0x7fff4c004e10) at /usr/include/c++/10/bits/atomic_base.h:325
#74 0x00007ffff6de7669 in ThreadWeaver::Executor::run(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*) (this=<optimized out>, job=..., thread=<optimized out>) at /usr/include/c++/10/bits/atomic_base.h:325
#75 0x00007ffff6de67d0 in ThreadWeaver::Job::execute(QSharedPointer<ThreadWeaver::JobInterface> const&, ThreadWeaver::Thread*) (this=<optimized out>, self=..., th=0x7fff4c004e10) at /home/luis/kde/src/threadweaver/src/job.cpp:65
#76 0x00007ffff6de613e in ThreadWeaver::Thread::run() (this=0x7fff4c004e10) at /usr/include/qt5/QtCore/qsharedpointer_impl.h:306
#77 0x00007ffff4181690 in QThreadPrivate::start(void*) (arg=0x7fff4c004e10) at thread/qthread_unix.cpp:342
#78 0x00007ffff33e1432 in start_thread (arg=<optimized out>) at pthread_create.c:477
#79 0x00007ffff3ca1913 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95



EXPECTED RESULT


SOFTWARE/OS VERSIONS
Operating System: Fedora 32
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.75.0
Qt Version: 5.14.2
Kernel Version: 5.10.7-100.fc32.x86_64
OS Type: 64-bit

ADDITIONAL INFORMATION
Comment 1 Milian Wolff 2021-01-22 09:31:11 UTC
what version of llvm are you using?
Comment 2 kogiokkafrms 2021-01-23 00:54:17 UTC
I'm using llvm-10.0.1. The rpm package is llvm-10.0.1-4.fc32.x86_64.
Comment 3 kogiokkafrms 2021-01-30 08:24:56 UTC
This issue doesn't occur on Fedora 33 with llvm-11.0.0. It might have been fixed at the upstream.
Comment 4 Igor Kushnir 2021-01-30 13:13:11 UTC
If other users experience this crash with LLVM version < 11, then KDevelop should probably disable the new feature by calling decl->setBitWidth(-1) when it is compiled against an older LLVM version.
Comment 5 Igor Kushnir 2022-06-02 07:33:33 UTC

*** This bug has been marked as a duplicate of bug 438249 ***