Bug 318492 - Crash due to infinite recursion in Cpp::TemplateDeclaration::setSpecializedFrom
Summary: Crash due to infinite recursion in Cpp::TemplateDeclaration::setSpecializedFrom
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: 4.3.0
Assignee: Andreas Pakulat
URL:
Keywords:
: 328467 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-04-17 08:33 UTC by Maciej Cencora
Modified: 2013-12-05 21:53 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Example project triggering this crash (1.46 KB, application/zip)
2013-07-30 10:42 UTC, Andreas Pakulat
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Maciej Cencora 2013-04-17 08:33:49 UTC
Kdevelop crashes when parsing some files with template functions.
I cannot provide the source code for the file - it is proprietary.


Reproducible: Always

Steps to Reproduce:
I cannot provide sample code to reproduce it , since I don't know how to isolate the affecting function. Any help?



Backtrace (50 outermost frames):

#104736 0x00007fffb5c91448 in Cpp::TemplateDeclaration::setSpecializedFrom (this=this@entry=0x7fff4c454328, other=0x7fff4d5e9eb8) at /home/mcencora/tmp/kdevelop/languages/cpp/cppduchain/templatedeclaration.cpp:391
#104737 0x00007fffb5c91448 in Cpp::TemplateDeclaration::setSpecializedFrom (this=this@entry=0x7fff4c454328, other=0x7fff4d5e9eb8) at /home/mcencora/tmp/kdevelop/languages/cpp/cppduchain/templatedeclaration.cpp:391
#104738 0x00007fffb5c91448 in Cpp::TemplateDeclaration::setSpecializedFrom (this=0x7fff4c454328, other=0x7fff4d5e9eb8) at /home/mcencora/tmp/kdevelop/languages/cpp/cppduchain/templatedeclaration.cpp:391
#104739 0x00007fffb5c5a38f in DeclarationBuilder::openDeclaration<KDevelop::FunctionDefinition> (this=this@entry=0x7fff61fbcb00, name=name@entry=0x7fff4d72c730, rangeNode=rangeNode@entry=0x7fff4d72c570, customName=..., 
    collapseRangeAtStart=collapseRangeAtStart@entry=false, collapseRangeAtEnd=collapseRangeAtEnd@entry=false) at /home/mcencora/tmp/kdevelop/languages/cpp/cppduchain/declarationbuilder.cpp:656
#104740 0x00007fffb5c402dd in DeclarationBuilder::openFunctionDeclaration (this=this@entry=0x7fff61fbcb00, name=0x7fff4d72c730, rangeNode=rangeNode@entry=0x7fff4d72c570)
    at /home/mcencora/tmp/kdevelop/languages/cpp/cppduchain/declarationbuilder.cpp:867
#104741 0x00007fffb5c420ce in DeclarationBuilder::visitDeclarator (this=0x7fff61fbcb00, node=0x7fff4d72c570) at /home/mcencora/tmp/kdevelop/languages/cpp/cppduchain/declarationbuilder.cpp:497
#104742 0x00007fffb5c43e2b in DeclarationBuilder::visitFunctionDeclaration (this=0x7fff61fbcb00, node=0x7fff4d72dbc8) at /home/mcencora/tmp/kdevelop/languages/cpp/cppduchain/declarationbuilder.cpp:181
#104743 0x00007fffb5c30dcb in ContextBuilder::visitFunctionDefinition (this=0x7fff61fbcb00, node=0x7fff4d72dbc8) at /home/mcencora/tmp/kdevelop/languages/cpp/cppduchain/contextbuilder.cpp:577
#104744 0x00007fffb5c3115e in ContextBuilder::visitTemplateDeclaration (this=0x7fff61fbcb00, ast=0x7fff4d72dc28) at /home/mcencora/tmp/kdevelop/languages/cpp/cppduchain/contextbuilder.cpp:293
#104745 0x00007fffb598a111 in visitNodes<DeclarationAST*> (v=0x7fff61fbcb60, nodes=<optimized out>) at /home/mcencora/tmp/kdevelop/languages/cpp/parser/visitor.h:139
#104746 0x00007fffb5c32541 in KDevelop::AbstractContextBuilder<AST, NameAST>::supportBuild (this=0x7fff61fbcb00, node=0x7fff4d45c7c0, context=<optimized out>)
    at /usr/local/include/kdevplatform/language/duchain/builders/abstractcontextbuilder.h:133
#104747 0x00007fffb5c2dff6 in ContextBuilder::buildContexts (this=0x7fff61fbcb00, file=..., node=0x7fff4d45c7c0, includes=<optimized out>, updateContext=..., removeOldImports=false)
    at /home/mcencora/tmp/kdevelop/languages/cpp/cppduchain/contextbuilder.cpp:422
#104748 0x00007fffb5c3bc42 in DeclarationBuilder::buildDeclarations (this=<optimized out>, file=..., node=<optimized out>, includes=<optimized out>, updateContext=..., removeOldImports=false)
    at /home/mcencora/tmp/kdevelop/languages/cpp/cppduchain/declarationbuilder.cpp:96
#104749 0x00007fffb615c36c in CPPInternalParseJob::run (this=0x84d75d0) at /home/mcencora/tmp/kdevelop/languages/cpp/cppparsejob.cpp:644
#104750 0x00007fffec682e3a in ThreadWeaver::JobRunHelper::runTheJob (this=this@entry=0x7fff61fbcd50, th=th@entry=0x7fff58002e50, job=job@entry=0x84d75d0) at ../../../threadweaver/Weaver/Job.cpp:106
#104751 0x00007fffec682fb1 in ThreadWeaver::Job::execute (this=0x84d75d0, th=0x7fff58002e50) at ../../../threadweaver/Weaver/Job.cpp:135
#104752 0x00007fffec684e23 in ThreadWeaver::JobCollectionJobRunner::execute (this=0x5ee9820, t=0x7fff58002e50) at ../../../threadweaver/Weaver/JobCollection.cpp:82
#104753 0x00007fffec68260f in ThreadWeaver::ThreadRunHelper::run (this=this@entry=0x7fff61fbcdc0, parent=0xe52430, th=th@entry=0x7fff58002e50) at ../../../threadweaver/Weaver/Thread.cpp:95
#104754 0x00007fffec6826cb in ThreadWeaver::Thread::run (this=0x7fff58002e50) at ../../../threadweaver/Weaver/Thread.cpp:142
#104755 0x00007ffff5ce7bec in QThreadPrivate::start (arg=0x7fff58002e50) at thread/qthread_unix.cpp:338
#104756 0x00007ffff3adbf8e in start_thread (arg=0x7fff61fbd700) at pthread_create.c:311
#104757 0x00007ffff49ede1d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113
Comment 1 Andreas Pakulat 2013-07-30 10:42:00 UTC
Created attachment 81450 [details]
Example project triggering this crash

The attached project allows to reproduce the problem. In the example project just copy/pasting the function worked for me, but as soon as I tried to edit the main.cpp further kdevelop crashed. In the real case where I encountered this KDevelop actually crashed already right after pasting the copy of the template specialization.

Even though the current state of the main.cpp does not compile, KDevelop shouldn't crash here since its just an intermediate step when writing a new specialization for the template function.
Comment 2 Andreas Pakulat 2013-07-30 10:55:27 UTC
Well turns out the second specialization does not even need to be using the same signature. The same issue occurs for me when changing the signature.
Comment 3 Andreas Pakulat 2013-07-31 22:29:15 UTC
Git commit 61e585a694addd4c4850e6019244732a9bb4f307 by Andreas Pakulat.
Committed on 31/07/2013 at 22:28.
Pushed by apaku into branch '4.5'.

Merge branch '318492/prevent_endless_recursion_setSpecializedFrom' into 4.5
REVIEW: 111796


http://commits.kde.org/kdevelop/61e585a694addd4c4850e6019244732a9bb4f307
Comment 4 Kevin Funk 2013-12-05 21:53:41 UTC
*** Bug 328467 has been marked as a duplicate of this bug. ***