https://bugs.kde.org/show_bug.cgi?id=423920

            Bug ID: 423920
           Summary: Erroneous lambda expression crashes KDevelop in C++17
                    mode with clang 10.0.1
           Product: kdevelop
           Version: 5.5.2
          Platform: Gentoo Packages
                OS: Linux
            Status: REPORTED
          Severity: crash
          Priority: NOR
         Component: Language Support: CPP (Clang-based)
          Assignee: kdevelop-bugs-n...@kde.org
          Reporter: k...@mattwhitlock.name
  Target Milestone: ---

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

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to