HaveF / include-what-you-use

Automatically exported from code.google.com/p/include-what-you-use
Other
0 stars 0 forks source link

Crash with vector #151

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

Hello

I noticed IWYU was crashing on some of our files, so I spent some time 
isolating the problem.

It finally came down to something very simple, so it's very surprising that it 
crashes.

The source is like this:

// vectorcrash.cpp : Defines the entry point for the console application.
//

#include <tchar.h>
#include <vector>

class CTest
{
    int m_test[2];
};

int _tmain(int argc, _TCHAR* argv[])
{
    std::vector <CTest> testVector;

    return 0;
}

Command line parameters: F:\tests\vectorcrash\vectorcrash\vectorcrash.cpp 
-DWIN32 -D_DEBUG -D_CONSOLE -w -g -O3 -ffast-math -funroll-loops -fno-rtti
Working directory: F:\tests\vectorcrash\vectorcrash\
Platform: Windows 64bits (compile settings for 64 bits as well)

The crash happens while parsing the AST, at the part where it calls 
HandleTranslationUnit, so it's possible it's a clang crash unrelated to IWYU.

If I change m_test to not be implemented as an array then there is no crash.

Here is the callstack, and I attach the solution to test as well:

>   include-what-you-use.exe!clang::Scope::getEntity() Line 274 C++
    include-what-you-use.exe!clang::Sema::PushOnScopeChains(clang::NamedDecl * D, clang::Scope * S, bool AddToContext) Line 1031    C++
    include-what-you-use.exe!clang::Sema::LazilyCreateBuiltin(clang::IdentifierInfo * II, unsigned int bid, clang::Scope * S, bool ForRedeclaration, clang::SourceLocation Loc) Line 1580   C++
    include-what-you-use.exe!LookupBuiltin(clang::Sema & S, clang::LookupResult & R) Line 541   C++
    include-what-you-use.exe!clang::Sema::LookupName(clang::LookupResult & R, clang::Scope * S, bool AllowBuiltinCreation) Line 1413    C++
    include-what-you-use.exe!buildMemcpyForAssignmentOp(clang::Sema & S, clang::SourceLocation Loc, clang::QualType T, const `anonymous-namespace'::ExprBuilder & ToB, const `anonymous-namespace'::ExprBuilder & FromB) Line 8944  C++
    include-what-you-use.exe!buildSingleCopyAssign(clang::Sema & S, clang::SourceLocation Loc, clang::QualType T, const `anonymous-namespace'::ExprBuilder & To, const `anonymous-namespace'::ExprBuilder & From, bool CopyingBaseSubobject, bool Copying) Line 9188    C++
    include-what-you-use.exe!clang::Sema::DefineImplicitMoveAssignment(clang::SourceLocation CurrentLocation, clang::CXXMethodDecl * MoveAssignOperator) Line 9953  C++
    include-what-you-use.exe!clang::Sema::MarkFunctionReferenced(clang::SourceLocation Loc, clang::FunctionDecl * Func) Line 11333  C++
    include-what-you-use.exe!clang::Sema::MarkAnyDeclReferenced(clang::SourceLocation Loc, clang::Decl * D, bool OdrUse) Line 12379 C++
    include-what-you-use.exe!MarkExprReferenced(clang::Sema & SemaRef, clang::SourceLocation Loc, clang::Decl * D, clang::Expr * E, bool OdrUse) Line 12320 C++
    include-what-you-use.exe!clang::Sema::MarkDeclRefReferenced(clang::DeclRefExpr * E) Line 12346  C++
    include-what-you-use.exe!clang::CreateFunctionRefExpr(clang::Sema & S, clang::FunctionDecl * Fn, clang::NamedDecl * FoundDecl, bool HadMultipleCandidates, clang::SourceLocation Loc, const clang::DeclarationNameLoc & LocInfo) Line 63    C++
    include-what-you-use.exe!clang::Sema::CreateOverloadedBinOp(clang::SourceLocation OpLoc, unsigned int OpcIn, const clang::UnresolvedSetImpl & Fns, clang::Expr * LHS, clang::Expr * RHS) Line 11002 C++
    include-what-you-use.exe!BuildOverloadedBinOp(clang::Sema & S, clang::Scope * Sc, clang::SourceLocation OpLoc, clang::BinaryOperatorKind Opc, clang::Expr * LHS, clang::Expr * RHS) Line 9610   C++
    include-what-you-use.exe!clang::Sema::BuildBinOp(clang::Scope * S, clang::SourceLocation OpLoc, clang::BinaryOperatorKind Opc, clang::Expr * LHSExpr, clang::Expr * RHSExpr) Line 9684  C++
    include-what-you-use.exe!clang::TreeTransform<`anonymous namespace'::TemplateInstantiator>::RebuildBinaryOperator(clang::SourceLocation OpLoc, clang::BinaryOperatorKind Opc, clang::Expr * LHS, clang::Expr * RHS) Line 1748   C++
    include-what-you-use.exe!clang::TreeTransform<`anonymous namespace'::TemplateInstantiator>::TransformBinaryOperator(clang::BinaryOperator * E) Line 6949    C++
    include-what-you-use.exe!clang::TreeTransform<`anonymous namespace'::TemplateInstantiator>::TransformExpr(clang::Expr * E) Line 157 C++
    include-what-you-use.exe!clang::TreeTransform<`anonymous namespace'::TemplateInstantiator>::TransformStmt(clang::Stmt * S) Line 2727    C++
    include-what-you-use.exe!clang::TreeTransform<`anonymous namespace'::TemplateInstantiator>::TransformForStmt(clang::ForStmt * S) Line 5648  C++
    include-what-you-use.exe!clang::TreeTransform<`anonymous namespace'::TemplateInstantiator>::TransformStmt(clang::Stmt * S) Line 739 C++
    include-what-you-use.exe!clang::TreeTransform<`anonymous namespace'::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt * S, bool IsStmtExpr) Line 5313   C++
    include-what-you-use.exe!clang::TreeTransform<`anonymous namespace'::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt * S) Line 5299    C++
    include-what-you-use.exe!clang::TreeTransform<`anonymous namespace'::TemplateInstantiator>::TransformStmt(clang::Stmt * S) Line 79  C++
    include-what-you-use.exe!clang::Sema::SubstStmt(clang::Stmt * S, const clang::MultiLevelTemplateArgumentList & TemplateArgs) Line 2578  C++
    include-what-you-use.exe!clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation PointOfInstantiation, clang::FunctionDecl * Function, bool Recursive, bool DefinitionRequired) Line 3435  C++
    include-what-you-use.exe!clang::Sema::PerformPendingInstantiations(bool LocalOnly) Line 4616    C++
    include-what-you-use.exe!clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation PointOfInstantiation, clang::FunctionDecl * Function, bool Recursive, bool DefinitionRequired) Line 3467  C++
    include-what-you-use.exe!clang::Sema::PerformPendingInstantiations(bool LocalOnly) Line 4616    C++
    include-what-you-use.exe!clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation PointOfInstantiation, clang::FunctionDecl * Function, bool Recursive, bool DefinitionRequired) Line 3467  C++
    include-what-you-use.exe!clang::Sema::PerformPendingInstantiations(bool LocalOnly) Line 4616    C++
    include-what-you-use.exe!clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation PointOfInstantiation, clang::FunctionDecl * Function, bool Recursive, bool DefinitionRequired) Line 3467  C++
    include-what-you-use.exe!clang::Sema::PerformPendingInstantiations(bool LocalOnly) Line 4616    C++
    include-what-you-use.exe!clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation PointOfInstantiation, clang::FunctionDecl * Function, bool Recursive, bool DefinitionRequired) Line 3467  C++
    include-what-you-use.exe!clang::Sema::PerformPendingInstantiations(bool LocalOnly) Line 4616    C++
    include-what-you-use.exe!include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::InstantiateImplicitMethods(clang::CXXRecordDecl * decl) Line 649  C++
    include-what-you-use.exe!include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::TraverseCXXConstructExpr(clang::CXXConstructExpr * expr) Line 839 C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseStmt(clang::Stmt * S) Line 189  C++
    include-what-you-use.exe!include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::TraverseStmt(clang::Stmt * stmt) Line 328 C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseVarHelper(clang::VarDecl * D) Line 1890 C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseVarDecl(clang::VarDecl * D) Line 1896   C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecl(clang::Decl * D) Line 391  C++
    include-what-you-use.exe!include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecl(clang::Decl * decl) Line 320 C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDeclStmt(clang::DeclStmt * S) Line 1980 C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseStmt(clang::Stmt * S) Line 91   C++
    include-what-you-use.exe!include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::TraverseStmt(clang::Stmt * stmt) Line 328 C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseCompoundStmt(clang::CompoundStmt * S) Line 1988 C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseStmt(clang::Stmt * S) Line 79   C++
    include-what-you-use.exe!include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::TraverseStmt(clang::Stmt * stmt) Line 328 C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseFunctionHelper(clang::FunctionDecl * D) Line 1847   C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseFunctionDecl(clang::FunctionDecl * D) Line 1856 C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecl(clang::Decl * D) Line 345  C++
    include-what-you-use.exe!include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecl(clang::Decl * decl) Line 320 C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDeclContextHelper(clang::DeclContext * DC) Line 1304    C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseTranslationUnitDecl(clang::TranslationUnitDecl * D) Line 1396   C++
    include-what-you-use.exe!clang::RecursiveASTVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecl(clang::Decl * D) Line 473  C++
    include-what-you-use.exe!include_what_you_use::BaseAstVisitor<include_what_you_use::IwyuAstConsumer>::TraverseDecl(clang::Decl * decl) Line 320 C++
    include-what-you-use.exe!include_what_you_use::IwyuAstConsumer::HandleTranslationUnit(clang::ASTContext & context) Line 3351    C++
    include-what-you-use.exe!clang::ParseAST(clang::Sema & S, bool PrintStats, bool SkipFunctionBodies) Line 156    C++
    include-what-you-use.exe!clang::ASTFrontendAction::ExecuteAction() Line 488 C++
    include-what-you-use.exe!clang::FrontendAction::Execute() Line 393  C++
    include-what-you-use.exe!clang::CompilerInstance::ExecuteAction(clang::FrontendAction & Act) Line 731   C++
    include-what-you-use.exe!main(int argc, char * * argv) Line 3753    C++
    include-what-you-use.exe!__tmainCRTStartup() Line 536   C

Original issue reported on code.google.com by dpun...@gmail.com on 18 Jun 2014 at 5:14

Attachments:

GoogleCodeExporter commented 9 years ago

Never mind, I updated all my sources to the latest llvm, clang and iwyu and 
it's ok now.

Original comment by dpun...@gmail.com on 19 Jun 2014 at 3:58

GoogleCodeExporter commented 9 years ago
OK, closing the issue.

Original comment by vsap...@gmail.com on 19 Jun 2014 at 10:19