Bug 326917 - Kdevelop crashes when auto variable references std::unique_ptr::release
Summary: Kdevelop crashes when auto variable references std::unique_ptr::release
Status: RESOLVED DUPLICATE of bug 318972
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: 4.5.1
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-31 00:16 UTC by Rafał Malinowski
Modified: 2013-10-31 12:02 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafał Malinowski 2013-10-31 00:16:03 UTC
I use C++11 features.

auto combined with std::unique_ptr::release results in crash.

Reproducible: Always

Steps to Reproduce:
1. Create C++/CMake project from template
2. Update CMakeLists.txt to allow C++11:

project(auto_crash)

set (CXX_FLAGS "-std=c++0x")
set_property (SOURCE main.cpp APPEND_STRING PROPERTY COMPILE_FLAGS " ${CXX_FLAGS}")
add_executable(auto_crash main.cpp)

install(TARGETS auto_crash RUNTIME DESTINATION bin)

3. Write following code in main.cpp:

#include <iostream>
#include <memory>

std::unique_ptr<int> get_int()
{
    return std::unique_ptr<int>(new int(12));
}

int main(int argc, char **argv) {
    std::cout << "Hello, world!" << std::endl;
    auto x = get_int().release();
    return x;
}
Actual Results:  
KDevelop crashes on auto x = get_int().release(); line

Expected Results:  
KDevelop does not crash
Comment 1 Kevin Funk 2013-10-31 08:41:53 UTC
Please provide a backtrace
Comment 2 Rafał Malinowski 2013-10-31 10:21:41 UTC
Here it is:

(gdb) backtrace 
#0  KDevelop::AbstractType::makeDynamic (this=this@entry=0x0) at ../../language/duchain/types/abstracttype.cpp:35
#1  0x00007ffff1c32081 in d_func_dynamic (this=0x0) at ../../language/duchain/types/abstracttype.h:284
#2  KDevelop::AbstractType::setModifiers (this=0x0, modifiers=0) at ../../language/duchain/types/abstracttype.cpp:57
#3  0x00007fffc6909186 in TypeBuilder::createIntegralTypeForExpression (this=0x7ffee9cd9ad0, expression=<optimized out>)
    at ../../../../languages/cpp/cppduchain/typebuilder.cpp:469
#4  0x00007fffc68da8fe in ContextBuilder::visitDeclarator (this=0x7ffee9cd9ad0, node=0x7ffee060ba08)
    at ../../../../languages/cpp/cppduchain/contextbuilder.cpp:937
#5  0x00007fffc68ed275 in DeclarationBuilder::visitDeclarator (this=0x7ffee9cd9ad0, node=0x7ffee060ba08)
    at ../../../../languages/cpp/cppduchain/declarationbuilder.cpp:532
#6  0x00007fffc68dbaf7 in ContextBuilder::visitInitDeclarator (this=this@entry=0x7ffee9cd9ad0, node=node@entry=0x7ffee060bdd0)
    at ../../../../languages/cpp/cppduchain/contextbuilder.cpp:912
#7  0x00007fffc68e911f in DeclarationBuilder::visitInitDeclarator (this=0x7ffee9cd9ad0, node=0x7ffee060bdd0)
    at ../../../../languages/cpp/cppduchain/declarationbuilder.cpp:256
#8  0x00007fffc690750c in TypeBuilder::visitSimpleDeclaration (this=this@entry=0x7ffee9cd9ad0, node=node@entry=0x7ffee060be10)
    at ../../../../languages/cpp/cppduchain/typebuilder.cpp:672
#9  0x00007fffc68ebac8 in DeclarationBuilder::visitSimpleDeclaration (this=0x7ffee9cd9ad0, node=0x7ffee060be10)
    at ../../../../languages/cpp/cppduchain/declarationbuilder.cpp:422
#10 0x00007fffc663a559 in visitNodes<StatementAST*> (nodes=<optimized out>, v=<optimized out>) at ../../../../languages/cpp/parser/visitor.h:139
#11 DefaultVisitor::visitCompoundStatement (this=this@entry=0x7ffee9cd9b30, node=node@entry=0x7ffee060b5a0)
    at ../../../../languages/cpp/parser/default_visitor.cpp:73
#12 0x00007fffc68da7cc in ContextBuilder::visitCompoundStatement (this=0x7ffee9cd9ad0, node=0x7ffee060b5a0)
    at ../../../../languages/cpp/cppduchain/contextbuilder.cpp:674
#13 0x00007fffc68da6ef in ContextBuilder::visitFunctionDefinition (this=0x7ffee9cd9ad0, node=0x7ffee060bfa8)
    at ../../../../languages/cpp/cppduchain/contextbuilder.cpp:592
#14 0x00007fffc663ae39 in visitNodes<DeclarationAST*> (v=0x7ffee9cd9b30, nodes=<optimized out>) at ../../../../languages/cpp/parser/visitor.h:139
#15 0x00007fffc68dcdc9 in KDevelop::AbstractContextBuilder<AST, NameAST>::supportBuild (this=0x7ffee9cd9ad0, node=0x7ffee060a300, context=<optimized out>)
    at /usr/include/kdevplatform/language/duchain/builders/abstractcontextbuilder.h:133
#16 0x00007fffc68dc32a in ContextBuilder::buildContexts (this=0x7ffee9cd9ad0, file=..., node=0x7ffee060a300, includes=<optimized out>, updateContext=..., 
    removeOldImports=removeOldImports@entry=false) at ../../../../languages/cpp/cppduchain/contextbuilder.cpp:422
#17 0x00007fffc68e7c12 in DeclarationBuilder::buildDeclarations (this=this@entry=0x7ffee9cd9ad0, file=..., node=node@entry=0x7ffee060a300, 
    includes=includes@entry=0x7ffee9cd9830, updateContext=..., removeOldImports=removeOldImports@entry=false)
    at ../../../../languages/cpp/cppduchain/declarationbuilder.cpp:96
#18 0x00007fffc6dfb27a in CPPInternalParseJob::run (this=<optimized out>) at ../../../languages/cpp/cppparsejob.cpp:644
#19 0x00007fffec638cb2 in ThreadWeaver::JobRunHelper::runTheJob (this=this@entry=0x7ffee9cd9d50, th=th@entry=0x35e7990, job=job@entry=0x41daf00)
    at ../../../threadweaver/Weaver/Job.cpp:106
#20 0x00007fffec638e6e in ThreadWeaver::Job::execute (this=0x41daf00, th=0x35e7990) at ../../../threadweaver/Weaver/Job.cpp:135
#21 0x00007fffec63a90b in ThreadWeaver::JobCollectionJobRunner::execute (this=0x9072f0, t=0x35e7990) at ../../../threadweaver/Weaver/JobCollection.cpp:82
#22 0x00007fffec6386bb in ThreadWeaver::Thread::run (this=0x35e7990) at ../../../threadweaver/Weaver/Thread.cpp:108
#23 0x00007ffff5ce0f2f in QThreadPrivate::start (arg=0x35e7990) at thread/qthread_unix.cpp:338
#24 0x00007ffff3ac4f6e in start_thread (arg=0x7ffee9cda700) at pthread_create.c:311
Comment 3 Milian Wolff 2013-10-31 12:02:01 UTC
fixed for kdev 4.5.2 and 4.6 (I'll announce the former officially now).

cheers

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