[LLVMbugs] [Bug 7101] New: Crash in codegen on local class access to static variable in containing function

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat May 8 17:52:11 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=7101

           Summary: Crash in codegen on local class access to static
                    variable in containing function
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jyasskin at google.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


$ cat crash_test.cc 
void foo() {
    static int n = 0;
    struct Helper {
        static void Execute() {
            n++;
        }
    };
    Helper::Execute();
}

-fsyntax-only and g++ complete successfully, but:

$ gdb --args /Users/jyasskin/src/llvm/clang/obj/Debug/bin/clang -cc1 -S -o
/dev/null crash_test.cc
(gdb) run
Starting program: /Users/jyasskin/src/llvm/clang/obj/Debug/bin/clang -cc1 -S -o
/dev/null crash_test.cc
Reading symbols for shared libraries +++. done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x65706c75
0x00190b4d in llvm::Type::getForwardedType (this=0x65706c65) at Type.h:357
357    public:
(gdb) bt
#0  0x00190b4d in llvm::Type::getForwardedType (this=0x65706c65) at Type.h:357
#1  0x0018b4b7 in llvm::PATypeHolder::get (this=0x1907c54) at Type.h:507
#2  0x0018b4f5 in llvm::PATypeHolder::operator llvm::Type* (this=0x1907c54) at
AbstractTypeUser.h:158
#3  0x0018b50c in llvm::Value::getType (this=0x1907c4c) at Value.h:110
#4  0x00174cf2 in clang::CodeGen::CodeGenFunction::EmitLoadOfLValue
(this=0xbfffdff0, LV={LVType = clang::CodeGen::LValue::Simple, V = 0x1907c4c,
{VectorIdx = 0xbfffd9f8, VectorElts = 0xbfffd9f8, BitFieldInfo = 0xbfffd9f8,
PropertyRefExpr = 0xbfffd9f8, KVCRefExpr = 0xbfffd9f8}, Quals = {Mask = 0},
Ivar = false, ObjIsArray = false, NonGC = false, GlobalObjCRef = false,
BaseIvarExp = 0x0}, ExprType={Value = {Value = 26229792}}) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CGExpr.cpp:595
#5  0x00175098 in clang::CodeGen::CodeGenFunction::EmitScalarPrePostIncDec
(this=0xbfffdff0, E=0x1907850, LV={LVType = clang::CodeGen::LValue::Simple, V =
0x1907c4c, {VectorIdx = 0xbfffd9f8, VectorElts = 0xbfffd9f8, BitFieldInfo =
0xbfffd9f8, PropertyRefExpr = 0xbfffd9f8, KVCRefExpr = 0xbfffd9f8}, Quals =
{Mask = 0}, Ivar = false, ObjIsArray = false, NonGC = false, GlobalObjCRef =
false, BaseIvarExp = 0x0}, isInc=true, isPre=false) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CGExpr.cpp:295
#6  0x001a1a42 in (anonymous namespace)::ScalarExprEmitter::VisitPrePostIncDec
(this=0xbfffdc30, E=0x1907850, isInc=true, isPre=false) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:214
#7  0x001a1a70 in (anonymous namespace)::ScalarExprEmitter::VisitUnaryPostInc
(this=0xbfffdc30, E=0x1907850) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:220
#8  0x001a4da8 in clang::StmtVisitor<(anonymous namespace)::ScalarExprEmitter,
llvm::Value*>::Visit (this=0xbfffdc30, S=0x1907850) at StmtVisitor.h:88
#9  0x0019afeb in clang::CodeGen::CodeGenFunction::EmitScalarExpr
(this=0xbfffdff0, E=0x1907850, IgnoreResultAssign=true) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CGExprScalar.cpp:1889
#10 0x0017324a in clang::CodeGen::CodeGenFunction::EmitAnyExpr
(this=0xbfffdff0, E=0x1907850, AggLoc=0x0, IsAggLocVolatile=false,
IgnoreResult=true, IsInitializer=false) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CGExpr.cpp:98
#11 0x001e6690 in clang::CodeGen::CodeGenFunction::EmitStmt (this=0xbfffdff0,
S=0x1907850) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CGStmt.cpp:74
#12 0x001e7f6b in clang::CodeGen::CodeGenFunction::EmitCompoundStmt
(this=0xbfffdff0, S=@0x1907870, GetLast=false, AggLoc=0x0, isAggVol=false) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CGStmt.cpp:160
#13 0x001e8158 in clang::CodeGen::CodeGenFunction::EmitSimpleStmt
(this=0xbfffdff0, S=0x1907870) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CGStmt.cpp:128
#14 0x001e63c8 in clang::CodeGen::CodeGenFunction::EmitStmt (this=0xbfffdff0,
S=0x1907870) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CGStmt.cpp:43
#15 0x0020b283 in clang::CodeGen::CodeGenFunction::EmitFunctionBody
(this=0xbfffdff0, Args=@0xbfffde80) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CodeGenFunction.cpp:250
#16 0x0020def7 in clang::CodeGen::CodeGenFunction::GenerateCode
(this=0xbfffdff0, GD={Value = {Value = 26243824}}, Fn=0x1908030) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CodeGenFunction.cpp:307
#17 0x002191af in clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition
(this=0x2032c00, GD={Value = {Value = 26243824}}) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:1339
#18 0x0021938c in clang::CodeGen::CodeGenModule::EmitGlobalDefinition
(this=0x2032c00, GD={Value = {Value = 26243824}}) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:740
#19 0x0021955a in clang::CodeGen::CodeGenModule::EmitDeferred (this=0x2032c00)
at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:530
#20 0x00219964 in clang::CodeGen::CodeGenModule::Release (this=0x2032c00) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/CodeGenModule.cpp:84
#21 0x00233a2a in (anonymous
namespace)::CodeGeneratorImpl::HandleTranslationUnit (this=0x1906190,
Ctx=@0x2023000) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/CodeGen/ModuleBuilder.cpp:83
#22 0x00023f68 in (anonymous namespace)::BackendConsumer::HandleTranslationUnit
(this=0x1906010, C=@0x2023000) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/Frontend/CodeGenAction.cpp:158
#23 0x002428e8 in clang::ParseAST (PP=@0x1903640, Consumer=0x1906010,
Ctx=@0x2023000, PrintStats=false, CompleteTranslationUnit=true,
CompletionConsumer=0x0) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/Sema/ParseAST.cpp:108
#24 0x00044d44 in clang::ASTFrontendAction::ExecuteAction (this=0x1903120) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/Frontend/FrontendAction.cpp:224
#25 0x00044c34 in clang::FrontendAction::Execute (this=0x1903120) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/Frontend/FrontendAction.cpp:150
#26 0x00025aeb in clang::CompilerInstance::ExecuteAction (this=0x19018c0,
Act=@0x1903120) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/lib/Frontend/CompilerInstance.cpp:511
#27 0x00003448 in cc1_main (ArgBegin=0xbffff678, ArgEnd=0xbffff688,
Argv0=0xbffff734 "/Users/jyasskin/src/llvm/clang/obj/Debug/bin/clang",
MainAddr=0x6278) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/tools/driver/cc1_main.cpp:285
#28 0x00007009 in main (argc=6, argv=0xbffff670) at
/Users/jyasskin/src/llvm/clang/src/tools/clang/tools/driver/driver.cpp:181
(gdb) 



Reduced from a crash in compiling googletest.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list