Bug 423920 - Erroneous lambda expression crashes KDevelop in C++17 mode with clang 10.0.1
Summary: Erroneous lambda expression crashes KDevelop in C++17 mode with clang 10.0.1
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (show other bugs)
Version: 5.5.2
Platform: Gentoo Packages Linux
: NOR crash
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-06 07:03 UTC by Matt Whitlock
Modified: 2022-10-28 02:38 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Whitlock 2020-07-06 07:03:27 UTC
SUMMARY

The presence of a certain erroneous lambda expression in C++ source code is enough to crash KDevelop when parsing using the "c++17" profile.


STEPS TO REPRODUCE

1. Create a new empty C++ project.

2. Add a file "bug.cpp" with the following contents:

struct NotCopyable {
	NotCopyable(const NotCopyable &) = delete;
	NotCopyable & operator=(const NotCopyable &) = delete;
};

auto foo(const NotCopyable &bug) {
	return [bug]() { };
}

3. Set project's C++ Profile to "c++17".


OBSERVED RESULT

KDevelop crashes (SIGSEGV) with the following backtrace:

#0  0x00007fff7e0158e4 in clang::cxcursor::MakeCXCursor(clang::Stmt const*, clang::Decl const*, CXTranslationUnitImpl*, clang::SourceRange) [clone .localalias] () from /usr/lib/llvm/10/lib64/libclang.so.10
#1  0x00007fff7dfec565 in clang::cxcursor::CursorVisitor::EnqueueWorkList(llvm::SmallVector<clang::cxcursor::VisitorJob, 10u>&, clang::Stmt const*) () from /usr/lib/llvm/10/lib64/libclang.so.10
#2  0x00007fff7e000acc in clang::cxcursor::CursorVisitor::Visit(clang::Stmt const*) () from /usr/lib/llvm/10/lib64/libclang.so.10
#3  0x00007fff7e00024c in clang::cxcursor::CursorVisitor::RunVisitorWorkList(llvm::SmallVector<clang::cxcursor::VisitorJob, 10u>&) () from /usr/lib/llvm/10/lib64/libclang.so.10
#4  0x00007fff7e000ad7 in clang::cxcursor::CursorVisitor::Visit(clang::Stmt const*) () from /usr/lib/llvm/10/lib64/libclang.so.10
#5  0x00007fff7dffa7cb in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) () from /usr/lib/llvm/10/lib64/libclang.so.10
#6  0x00007fff7e00269e in clang_visitChildren () from /usr/lib/llvm/10/lib64/libclang.so.10
#7  0x00007fff91daa900 in (anonymous namespace)::Visitor::buildCompoundStatement<(CXCursorKind)144> (cursor=..., this=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/g++-v10/bits/move.h:101
#8  (anonymous namespace)::visitCursor (cursor=..., parent=..., data=0x7fffabffea80) at ../kdevelop-5.5.2/plugins/clang/duchain/builder.cpp:1592
#9  0x00007fff7e0006de in clang::cxcursor::CursorVisitor::RunVisitorWorkList(llvm::SmallVector<clang::cxcursor::VisitorJob, 10u>&) () from /usr/lib/llvm/10/lib64/libclang.so.10
#10 0x00007fff7e000ad7 in clang::cxcursor::CursorVisitor::Visit(clang::Stmt const*) () from /usr/lib/llvm/10/lib64/libclang.so.10
#11 0x00007fff7dffa7cb in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) () from /usr/lib/llvm/10/lib64/libclang.so.10
#12 0x00007fff7e00269e in clang_visitChildren () from /usr/lib/llvm/10/lib64/libclang.so.10
#13 0x00007fff91daa900 in (anonymous namespace)::Visitor::buildCompoundStatement<(CXCursorKind)144> (cursor=..., this=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/g++-v10/bits/move.h:101
#14 (anonymous namespace)::visitCursor (cursor=..., parent=..., data=0x7fffabffea80) at ../kdevelop-5.5.2/plugins/clang/duchain/builder.cpp:1592
#15 0x00007fff7dffacae in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) () from /usr/lib/llvm/10/lib64/libclang.so.10
#16 0x00007fff7dfff7c8 in clang::cxcursor::CursorVisitor::VisitFunctionDecl(clang::FunctionDecl*) () from /usr/lib/llvm/10/lib64/libclang.so.10
#17 0x00007fff7dffa837 in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) () from /usr/lib/llvm/10/lib64/libclang.so.10
#18 0x00007fff7e00269e in clang_visitChildren () from /usr/lib/llvm/10/lib64/libclang.so.10
#19 0x00007fff91d8fdb2 in (anonymous namespace)::Visitor::buildDeclaration<(CXCursorKind)8, KDevelop::FunctionDefinition, true> (this=this@entry=0x7fffabffea80, cursor=...) at /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/g++-v10/bits/move.h:101
#20 0x00007fff91dac14d in (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)8, (Decision)1, (Decision)0> (parent=..., cursor=..., this=0x7fffabffea80) at ../kdevelop-5.5.2/plugins/clang/duchain/builder.cpp:942
#21 (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)8> (parent=..., cursor=..., this=0x7fffabffea80) at ../kdevelop-5.5.2/plugins/clang/duchain/builder.cpp:936
#22 (anonymous namespace)::visitCursor (cursor=..., parent=..., data=0x7fffabffea80) at ../kdevelop-5.5.2/plugins/clang/duchain/builder.cpp:1549
#23 0x00007fff7dffacae in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool) () from /usr/lib/llvm/10/lib64/libclang.so.10
#24 0x00007fff7dffb6d5 in clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl const*) () from /usr/lib/llvm/10/lib64/libclang.so.10
#25 0x00007fff7dffb8d8 in clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*) () from /usr/lib/llvm/10/lib64/libclang.so.10
#26 0x00007fff7dffaac2 in clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) () from /usr/lib/llvm/10/lib64/libclang.so.10
#27 0x00007fff7e00269e in clang_visitChildren () from /usr/lib/llvm/10/lib64/libclang.so.10
#28 0x00007fff91d8cf7c in (anonymous namespace)::Visitor::Visitor (update=<optimized out>, includes=..., file=<optimized out>, tu=<optimized out>, this=0x7fffabffea80) at ../kdevelop-5.5.2/plugins/clang/duchain/builder.cpp:1464
#29 Builder::visit (tu=<optimized out>, file=<optimized out>, includes=..., update=<optimized out>) at ../kdevelop-5.5.2/plugins/clang/duchain/builder.cpp:1611
#30 0x00007fff91db808f in ClangHelpers::buildDUChain(void*, QMultiHash<void*, Import> const&, ParseSession const&, KDevelop::TopDUContext::Features, QHash<void*, KDevelop::ReferencedTopDUContext>&, ClangIndex*, std::function<bool ()> const&) (file=<optimized out>, imports=..., session=..., features=<optimized out>, includedFiles=..., index=0x555556104710, abortFunction=...) at ../kdevelop-5.5.2/plugins/clang/duchain/clanghelpers.cpp:201
#31 0x00007fff91e474dc in ClangParseJob::run (this=<optimized out>) at ../kdevelop-5.5.2/plugins/clang/clangparsejob.cpp:222
#32 0x00007ffff2a15047 in ThreadWeaver::IdDecorator::run (this=<optimized out>, self=..., thread=0x7fffa00032e0) at /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/g++-v10/bits/atomic_base.h:325
#33 0x00007ffff2a155b8 in ThreadWeaver::Executor::run (this=<optimized out>, job=..., thread=<optimized out>) at /usr/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include/g++-v10/bits/atomic_base.h:325
#34 0x00007ffff2a14670 in ThreadWeaver::Job::execute (this=<optimized out>, self=..., th=0x7fffa00032e0) at ../threadweaver-5.71.0/src/job.cpp:65
#35 0x00007ffff2a13f8b in ThreadWeaver::Thread::run (this=0x7fffa00032e0) at /usr/include/qt5/QtCore/qsharedpointer_impl.h:306
#36 0x00007ffff637c1f1 in QThreadPrivate::start (arg=0x7fffa00032e0) at ../../../qtbase-everywhere-src-5.15.0/src/corelib/thread/qthread_unix.cpp:342
#37 0x00007ffff3381e67 in start_thread (arg=<optimized out>) at pthread_create.c:477
#38 0x00007ffff601138f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95


EXPECTED RESULT

KDevelop reports the following error in the source code:

bug.cpp:7:10: error: call to deleted constructor of 'const NotCopyable'
        return [bug]() { };
                ^~~
bug.cpp:2:2: note: 'NotCopyable' has been explicitly marked deleted here
        NotCopyable(const NotCopyable &) = delete;
        ^
1 error generated.


SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.19.2
KDE Frameworks Version: 5.71.0
Qt Version: 5.15.0
Clang/LLVM Version: 10.0.1 RC2
Comment 1 Justin Zobel 2022-10-12 03:49:55 UTC
Thank you for reporting this crash in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the crash with a recent software version?

If you can reproduce the issue, please change the status to "CONFIRMED" when replying. Thank you!
Comment 2 Bug Janitor Service 2022-10-27 05:04:13 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Matt Whitlock 2022-10-28 02:38:23 UTC
My "Steps To Reproduce" no longer reproduce the crash on KDevelop 5.9.220802, so I'd guess this bug was fixed at some point. Thanks.