Bug 451856 - kdevelop crashes while parsing /usr/lib64/python3.6/html/entities.py or /usr/lib64/python3.6/email/message.py
Summary: kdevelop crashes while parsing /usr/lib64/python3.6/html/entities.py or /usr...
Status: REPORTED
Alias: None
Product: kdevelop
Classification: Applications
Component: Analyzer: Clazy (show other bugs)
Version: 5.7.211203
Platform: openSUSE Linux
: NOR crash
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-24 13:32 UTC by Aaron Williams
Modified: 2023-03-19 07:04 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
gcc toolchain tree-affine.h (3.80 KB, text/x-chdr)
2022-03-24 14:39 UTC, Aaron Williams
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Williams 2022-03-24 13:32:31 UTC
SUMMARY
When I open my project and Kdevelop parses it, it's crashing while it attempts to parse the system Python files. In this case, it crashes when it hits /usr/lib64/python3.6/html/entities.py

[New Thread 0x7fff7b554700 (LWP 18051)]
[New Thread 0x7fff79d51700 (LWP 18054)]
[New Thread 0x7fff840a6700 (LWP 18045)]
[New Thread 0x7fff7c556700 (LWP 18049)]
[New Thread 0x7fff7cd57700 (LWP 18048)]
[New Thread 0x7fff830a4700 (LWP 18046)]
[New Thread 0x7fff7ad53700 (LWP 18052)]
[New Thread 0x7fff7a552700 (LWP 18053)]
[New Thread 0x7fff7bd55700 (LWP 18050)]
[New Thread 0x7fff838a5700 (LWP 18044)]
[Thread 0x7fff7dd59700 (LWP 18042) exited]

Thread 35 "Queue(0x5555562" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff95995700 (LWP 13509)]
0x00007fff8e929ca8 in clang::ASTContext::getTypeInfoImpl (this=0x555561179310, T=<optimized out>) at ../tools/clang/include/clang/AST/Type.h:5641
5641      QualType desugar() const { return isSugared() ? Pattern : QualType(this, 0); }
(gdb) bt
#0  0x00007fff8e929ca8 in clang::ASTContext::getTypeInfoImpl (this=0x555561179310, T=<optimized out>) at ../tools/clang/include/clang/AST/Type.h:5641
#1  0x00007fff8e92b1bf in clang::ASTContext::getTypeInfo (this=0x555561179310, T=0x555566b206f0) at ../tools/clang/lib/AST/ASTContext.cpp:1867
#2  0x00007fff8ebb20a6 in clang::ASTContext::getTypeAlign (this=0x555561179310, T=0x7fff90fbc024) at ../tools/clang/include/clang/AST/ASTContext.h:2108
#3  clang::ASTContext::getTypeAlignInChars (this=0x555561179310, T=0x7fff90fbc024) at ../tools/clang/lib/AST/ASTContext.cpp:2380
#4  GetAlignOfType (Info=..., T=..., ExprKind=clang::UETT_AlignOf) at ../tools/clang/lib/AST/ExprConstant.cpp:8468
#5  0x00007fff8eb90a48 in (anonymous namespace)::IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr (this=0x7fff95991dc0, E=0x555566b20988)
    at ../tools/clang/lib/AST/ExprConstant.cpp:12524
#6  clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::IntExprEvaluator, bool>::Visit (this=0x7fff95991dc0, S=0x555566b20988)
    at tools/clang/include/clang/AST/StmtNodes.inc:1373
#7  0x00007fff8eb5d78c in Evaluate (Result=..., Info=..., E=0x555566b20988) at ../tools/clang/lib/AST/ExprConstant.cpp:13949
#8  0x00007fff8eb60d41 in EvaluateAsRValue (Info=..., E=0x555566b20988, Result=...) at ../tools/clang/lib/AST/ExprConstant.cpp:14057
#9  0x00007fff8eb607f7 in EvaluateAsRValue (E=0x555566b20988, Result=..., Ctx=..., Info=...) at ../tools/clang/lib/AST/ExprConstant.cpp:14114
#10 clang::Expr::EvaluateKnownConstInt (this=0x555566b20988, Ctx=..., Diag=<optimized out>) at ../tools/clang/lib/AST/ExprConstant.cpp:14363
#11 0x00007fff8ead0dfe in clang::AlignedAttr::getAlignment (this=0x555566a5e249, Ctx=...) at tools/clang/include/clang/AST/AttrImpl.inc:1522
#12 clang::Decl::getMaxAlignment (this=<optimized out>) at ../tools/clang/lib/AST/DeclBase.cpp:438
#13 0x00007fff8ed127e4 in (anonymous namespace)::ItaniumRecordLayoutBuilder::InitializeLayout (this=0x7fff95992568, D=0x555566b209a8)
    at ../tools/clang/lib/AST/RecordLayoutBuilder.cpp:1281
#14 0x00007fff8ed0a7b1 in (anonymous namespace)::ItaniumRecordLayoutBuilder::Layout (this=0x7fff95992568, RD=<optimized out>)
    at ../tools/clang/lib/AST/RecordLayoutBuilder.cpp:1314
#15 clang::ASTContext::getASTRecordLayout (this=<optimized out>, D=0x555566b209a8) at ../tools/clang/lib/AST/RecordLayoutBuilder.cpp:3084
#16 0x00007fff8e92a34d in clang::ASTContext::getTypeInfoImpl (this=0x555561179310, T=0x555566b20a40) at ../tools/clang/lib/AST/ASTContext.cpp:2234
#17 0x00007fff8e92b1bf in clang::ASTContext::getTypeInfo (this=0x555561179310, T=0x555566b20a40) at ../tools/clang/lib/AST/ASTContext.cpp:1867
#18 0x00007fff8e92b086 in clang::ASTContext::getTypeInfoInChars (this=0x555561179310, T=0x555566b20a40) at ../tools/clang/lib/AST/ASTContext.cpp:1819
#19 0x00007fff9162a0e5 in (anonymous namespace)::Visitor::setTypeSize (type=..., kdevType=kdevType@entry=0x5555692dc200, this=0x7fff95994400)
    at /usr/src/debug/kdevelop5-21.12.3-lp153.11.2.x86_64/plugins/clang/duchain/builder.cpp:927
#20 0x00007fff9163bffa in (anonymous namespace)::Visitor::createDeclaration<(CXCursorKind)2, KDevelop::ClassDeclaration> (context=0x5555691f5f20, id=..., cursor=...,
    this=0x7fff95994400) at /usr/src/debug/kdevelop5-21.12.3-lp153.11.2.x86_64/plugins/clang/duchain/builder.cpp:456
#21 (anonymous namespace)::Visitor::buildDeclaration<(CXCursorKind)2, KDevelop::ClassDeclaration, true> (cursor=..., this=0x7fff95994400)
    at /usr/src/debug/kdevelop5-21.12.3-lp153.11.2.x86_64/plugins/clang/duchain/builder.cpp:1211
#22 (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)2, (Decision)0, (Decision)0> (parent=..., cursor=..., this=0x7fff95994400)
    at /usr/src/debug/kdevelop5-21.12.3-lp153.11.2.x86_64/plugins/clang/duchain/builder.cpp:984
#23 (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)2, (Decision)0, (Decision)2> (this=0x7fff95994400, cursor=..., parent=...)
    at /usr/src/debug/kdevelop5-21.12.3-lp153.11.2.x86_64/plugins/clang/duchain/builder.cpp:958
#24 0x00007fff9164b60e in (anonymous namespace)::Visitor::dispatchCursor<(CXCursorKind)2> (parent=..., cursor=..., this=0x7fff95994400)
    at /usr/src/debug/kdevelop5-21.12.3-lp153.11.2.x86_64/plugins/clang/duchain/builder.cpp:946
#25 (anonymous namespace)::visitCursor (cursor=..., parent=..., data=0x7fff95994400) at /usr/src/debug/kdevelop5-21.12.3-lp153.11.2.x86_64/plugins/clang/duchain/builder.cpp:1550
#26 0x00007fff91c04690 in clang::cxcursor::CursorVisitor::Visit (this=0x7fff959941e0, Cursor=..., CheckedRegionOfInterest=true) at ../tools/clang/tools/libclang/CIndex.cpp:213
#27 clang::cxcursor::CursorVisitor::handleDeclForVisitation (this=0x7fff959941e0, D=0x555566b209a8) at ../tools/clang/tools/libclang/CIndex.cpp:675
#28 0x00007fff91c047c8 in clang::cxcursor::CursorVisitor::VisitDeclContext (this=0x7fff959941e0, DC=<optimized out>) at ../tools/clang/tools/libclang/CIndex.cpp:636
#29 0x00007fff91c00eef in clang::cxcursor::CursorVisitor::VisitChildren (this=0x7fff959941e0, Cursor=...) at ../tools/clang/tools/libclang/CIndex.cpp:536
#30 0x00007fff91c11696 in clang_visitChildren (parent=..., visitor=visitor@entry=0x7fff91649f00 <(anonymous namespace)::visitCursor(CXCursor, CXCursor, CXClientData)>,
    client_data=0x7fff90fbc024, client_data@entry=0x7fff95994400) at ../tools/clang/tools/libclang/CIndex.cpp:4500
#31 0x00007fff916313fe in (anonymous namespace)::Visitor::Visitor (update=<optimized out>, includes=..., file=<optimized out>, tu=<optimized out>, this=0x7fff95994400)
    at /usr/src/debug/kdevelop5-21.12.3-lp153.11.2.x86_64/plugins/clang/duchain/builder.cpp:1471
#32 Builder::visit (tu=<optimized out>, file=<optimized out>, includes=..., update=<optimized out>)
    at /usr/src/debug/kdevelop5-21.12.3-lp153.11.2.x86_64/plugins/clang/duchain/builder.cpp:1618
#33 0x00007fff9165aced 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=0x55555e572160,
    abortFunction=...) at /usr/src/debug/kdevelop5-21.12.3-lp153.11.2.x86_64/plugins/clang/duchain/clanghelpers.cpp:207
#34 0x00007fff9165a67f 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=0x55555e572160, abortFunction=...)
    at /usr/src/debug/kdevelop5-21.12.3-lp153.11.2.x86_64/plugins/clang/duchain/clanghelpers.cpp:121
#35 0x00007fff918c514f in ClangParseJob::run (this=0x555563b02530) at /usr/src/debug/kdevelop5-21.12.3-lp153.11.2.x86_64/plugins/clang/clangparsejob.cpp:326
#36 0x00007fffea527cba in ThreadWeaver::IdDecorator::run (this=<optimized out>, self=..., thread=0x55555e22bbd0)
    at /usr/src/debug/threadweaver-5.92.0-lp153.230.1.x86_64/src/iddecorator.cpp:50
#37 0x00007fffea5278e8 in ThreadWeaver::Executor::run (this=<optimized out>, job=..., thread=<optimized out>)
    at /usr/src/debug/threadweaver-5.92.0-lp153.230.1.x86_64/src/executor.cpp:33
#38 0x00007fffea528430 in ThreadWeaver::Job::execute (this=<optimized out>, self=..., th=0x55555e22bbd0) at /usr/src/debug/threadweaver-5.92.0-lp153.230.1.x86_64/src/job.cpp:64
#39 0x00007fffea52c05d in ThreadWeaver::Thread::run (this=0x55555e22bbd0) at /usr/src/debug/threadweaver-5.92.0-lp153.230.1.x86_64/src/thread.cpp:98
#40 0x00007ffff49239cc in QThreadPrivate::start (arg=0x55555e22bbd0) at thread/qthread_unix.cpp:331
#41 0x00007fffecb736ea in start_thread () from /lib64/libpthread.so.0
#42 0x00007ffff4155a8f in clone () from /lib64/libc.so.6

STEPS TO REPRODUCE
1.  Start kdevelop with my project
2. Wait while the background parser runs
3. Watch it crash

OBSERVED RESULT
It crashes

EXPECTED RESULT
I expect it not to crash

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: OpenSUSE 15.3/Plasma 5.24.3
(available in About System)
KDE Plasma Version: 5..24.3
KDE Frameworks Version: 5.92.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
clang version 11
Comment 1 Aaron Williams 2022-03-24 13:49:35 UTC
I see the following output when kdevelop is parsing:

[Detaching after fork from child process 63268]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63282]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63298]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63315]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63331]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63348]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63363]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63378]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63393]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63408]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63424]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63439]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63455]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63471]
kdevelop.plugins.customscript: indent returned empty text for style "autopep8" "/usr/bin/autopep8 -i $TMPFILE"
[Detaching after fork from child process 63486]
[Detaching after fork from child process 63487]
[Detaching after fork from child process 63490]
kdevelop.plugins.welcomepage: "Last fetch of news feed was on Wed Mar 23 22:05:44 2022 GMT-0700"
[Detaching after fork from child process 63497]

Note that it doesn't always crash on the same file either. This time it is crashing on /usr/lib64/python3.6/email/message.py

This may be related to bug #426292
Comment 2 Aaron Williams 2022-03-24 13:51:56 UTC
In OpenSUSE these files are part of python3-base-3.6.15-150300.10.21.1.x86_64
Comment 3 Aaron Williams 2022-03-24 14:20:12 UTC
It looks like it is crashing on other non-Python files as well. It's possible that this is an issue with OpenSUSE since I see that the version for most of KDevelop is 21.12.3-lp153.10.8 however the Python plugin is 21.12.3-lp153.10.1. After uninstalling the Python plugin it is still crashing. Now I am seeing the following error:


KCrash: Application 'kdevelop' crashing...
The X11 connection broke (error 1). Did the X11 server die?
DUContextData::m_importers There were items left on destruction: 601
DUContextData::m_importedContexts There were items left on destruction: 1160
TopDUContextData::m_usedDeclarationIds There were items left on destruction: 720
ClassFunctionDeclarationData::m_defaultParameters There were items left on destruction: 1316
MacroDefinitionData::parameters There were items left on destruction: 5791
malloc(): smallbin double linked list corrupted
Unable to start Dr. Konqi
Re-raising signal for core dump handling.
Comment 4 Aaron Williams 2022-03-24 14:24:58 UTC
I am also seeing this crash during background parsing. Is there some way to disable it?

Thread 39 "Queue(0x5555562" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff949cc700 (LWP 5135)]
0x00007fff9039d312 in clang::ASTContext::getTypeInfoImpl (this=0x555562eacc20, T=<optimized out>) at ../tools/clang/include/clang/AST/Type.h:4480
4480      QualType getUnderlyingType() const { return TOType; }
Comment 5 Aaron Williams 2022-03-24 14:39:53 UTC
Created attachment 147707 [details]
gcc toolchain tree-affine.h

File where parser is crashing
Comment 6 Aaron Williams 2022-03-24 14:54:36 UTC
With this last crash the issue appears to be a bit different. This looks like a stack overflow due to a loop:

Thread 25 "Queue(0x5555561" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff9d47f700 (LWP 21318)]
0x00007fff8fc0b312 in clang::ASTContext::getTypeInfoImpl (this=0x555563f0ff80, T=<optimized out>) at ../tools/clang/include/clang/AST/Type.h:4480
4480      QualType getUnderlyingType() const { return TOType; }

(gdb) bt
#0  0x00007fff8fc0b312 in clang::ASTContext::getTypeInfoImpl (this=0x555563f0ff80, T=<optimized out>) at ../tools/clang/include/clang/AST/Type.h:4480
#1  0x00007fff8fc0c1bf in clang::ASTContext::getTypeInfo (this=0x555563f0ff80, T=0x5555612b0470) at ../tools/clang/lib/AST/ASTContext.cpp:1867
#2  0x00007fff8fc0b317 in clang::ASTContext::getTypeInfoImpl (this=0x555563f0ff80, T=<optimized out>) at ../tools/clang/include/clang/AST/Type.h:4480
#3  0x00007fff8fc0c1bf in clang::ASTContext::getTypeInfo (this=0x555563f0ff80, T=0x5555612b0470) at ../tools/clang/lib/AST/ASTContext.cpp:1867
#4  0x00007fff8fc0b317 in clang::ASTContext::getTypeInfoImpl (this=0x555563f0ff80, T=<optimized out>) at ../tools/clang/include/clang/AST/Type.h:4480
#5  0x00007fff8fc0c1bf in clang::ASTContext::getTypeInfo (this=0x555563f0ff80, T=0x5555612b0470) at ../tools/clang/lib/AST/ASTContext.cpp:1867
#6  0x00007fff8fc0b317 in clang::ASTContext::getTypeInfoImpl (this=0x555563f0ff80, T=<optimized out>) at ../tools/clang/include/clang/AST/Type.h:4480
#7  0x00007fff8fc0c1bf in clang::ASTContext::getTypeInfo (this=0x555563f0ff80, T=0x5555612b0470) at ../tools/clang/lib/AST/ASTContext.cpp:1867
#8  0x00007fff8fc0b317 in clang::ASTContext::getTypeInfoImpl (this=0x555563f0ff80, T=<optimized out>) at ../tools/clang/include/clang/AST/Type.h:4480
#9  0x00007fff8fc0c1bf in clang::ASTContext::getTypeInfo (this=0x555563f0ff80, T=0x5555612b0470) at ../tools/clang/lib/AST/ASTContext.cpp:1867
...
Comment 7 Aaron Williams 2022-03-24 14:59:51 UTC
It is not always crashing on the same file though I am seeing the same loop behavior.
Comment 8 Aaron Williams 2022-03-24 15:06:01 UTC
I was finally able to get kdevelop to come up without crashing. I had to temporarily delete the symlinks to the two toolchains while it was parsing then re-create the symlinks afterwards. It seems that something in the arm-none-eabi toolchain is causing the Kdevelop parser to crash. After doing this I have added the tools and tools-scp symlinks to be excluded from the project.
Comment 9 Christian Andersen 2023-03-19 07:04:44 UTC
On my Teensy C++ projects (Arduino style using an Arm processor).
Kdevelop crashes while doing background parsing if there are too many symbolic links in the path to libraries or sources,
It seems like it generates a recursive loop that finally crashes Kdevelop.
I am using Ubuntu 22.04, where it fails. It worked fine with Ubuntu 20.04.
When most symbolic links are replaced with real files, then everything works fine.