[LLVMbugs] [Bug 7658] New: Segmentation fault during refineAbstractTypeTo with certain structure types and ConstantStruct objects

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jul 15 21:36:24 PDT 2010


           Summary: Segmentation fault during refineAbstractTypeTo with
                    certain structure types and ConstantStruct objects
           Product: libraries
           Version: 2.7
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Core LLVM classes
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: clemahieu at gmail.com
                CC: llvmbugs at cs.uiuc.edu

The following crashes on the last line "o4->refineAbstractTypeTo(h2->get());"


#include <stdio.h>
#include <vector>
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Type.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Constants.h"
#include "llvm/GlobalValue.h"

using namespace llvm;
using namespace std;

int main (int argc, const char * argv[]) {
    LLVMContext * ctx;
    StringRef * name;
    Module * m;
    vector <Type *> * t1;
    vector <Constant *> * v1;
    OpaqueType * o1;
    OpaqueType * o2;
    PointerType * p1;
    PointerType * p2;
    StructType * s1;
    PATypeHolder * h1;
    vector <Type *> * t2;
    vector <Constant *> * v2;
    OpaqueType * o3;
    OpaqueType * o4;
    PointerType * p3;
    PointerType * p4;
    Constant * c;
    StructType * s2;
    PATypeHolder * h2;

    ctx = new LLVMContext;
    name = new StringRef ("test");
    m = new Module (*name, *ctx);

    t1 = new vector <Type *>;
    v1 = new vector <Constant *>;
    o1 = OpaqueType::get(*ctx);
    p1 = PointerType::get(o1, 0);
    t1->push_back ((IntegerType *)IntegerType::get(*ctx, 32));
    v1->push_back (ConstantInt::get(IntegerType::get(*ctx, 32), 14));
    t1->push_back (p1);
    v1->push_back (ConstantPointerNull::get(p1));
    o2 = OpaqueType::get (*ctx);
    p2 = PointerType::get (o2, 0);
    t1->push_back (p2);
    v1->push_back (ConstantPointerNull::get (p2));
    s1 = StructType::get (*ctx, *((const vector <const Type *> *) t1));
    h1 = new PATypeHolder (s1);

    t2 = new vector <Type *>;
    v2 = new vector <Constant *>;
    o3 = OpaqueType::get(*ctx);
    p3 = PointerType::get(o3, 0);
    t2->push_back ((IntegerType *)IntegerType::get(*ctx, 32));
    v2->push_back (ConstantInt::get(IntegerType::get(*ctx, 32), 14));
    t2->push_back (p3);
    v2->push_back (ConstantPointerNull::get(p3));
    o4 = OpaqueType::get (*ctx);
    p4 = PointerType::get (o4, 0);
    t2->push_back (p4);
    v2->push_back (ConstantPointerNull::get (p4));
    c = ConstantStruct::get(*ctx, *v2, false);
    s2 = StructType::get (*ctx, *((const vector <const Type *> *) t2));
    h2 = new PATypeHolder (s2);

the call stack is:

#0    0x1000d56fa in llvm::Value::getValueID at Value.h:247
#1    0x1000366c9 in llvm::isa_impl<llvm::Constant, llvm::Value> at Value.h:329
#2    0x10003994f in llvm::isa_impl_wrap<llvm::Constant, llvm::Value const,
llvm::Value const>::doit at Casting.h:71
#3    0x100039969 in llvm::isa_impl_cl<llvm::Value>::isa<llvm::Constant> at
#4    0x100039983 in llvm::isa_impl_cl<llvm::Value*>::isa<llvm::Constant> at
#5    0x10002a780 in llvm::isa_impl_cl<llvm::Value* const>::isa<llvm::Constant>
at Casting.h:92
#6    0x10003a938 in llvm::isa_impl_wrap<llvm::Constant, llvm::Use const,
llvm::Value*>::doit at Casting.h:63
#7    0x10002a79b in llvm::isa_impl_cl<llvm::Use>::isa<llvm::Constant> at
#8    0x10002a7b5 in llvm::isa<llvm::Constant, llvm::Use> at Casting.h:116
#9    0x100041c1f in llvm::cast<llvm::Constant, llvm::Use> at Casting.h:200
#10    0x10004211f in llvm::ConstantStruct::getOperand at Constants.h:460
#11    0x1000ab348 in llvm::ConstantKeyData<llvm::ConstantStruct>::getValType
at ConstantsContext.h:475
#12    0x1000ac5f1 in llvm::ConstantUniqueMap<std::vector<llvm::Constant*,
std::allocator<llvm::Constant*> >, llvm::StructType, llvm::ConstantStruct,
true>::refineAbstractType at ConstantsContext.h:741
#13    0x1000d52eb in llvm::DerivedType::unlockedRefineAbstractTypeTo at
#14    0x1000e62fe in llvm::TypeMap<llvm::StructValType,
llvm::StructType>::RefineAbstractType at TypesContext.h:409
#15    0x1000d5454 in llvm::StructType::refineAbstractType at Type.cpp:1267
#16    0x1000d52eb in llvm::DerivedType::unlockedRefineAbstractTypeTo at
#17    0x1000e55c5 in llvm::TypeMap<llvm::PointerValType,
llvm::PointerType>::RefineAbstractType at TypesContext.h:409
#18    0x1000d53d0 in llvm::PointerType::refineAbstractType at Type.cpp:1297
#19    0x1000d52eb in llvm::DerivedType::unlockedRefineAbstractTypeTo at
#20    0x1000d5539 in llvm::DerivedType::refineAbstractTypeTo at Type.cpp:1193
#21    0x100008158 in main at main.cpp:76

inside llvm::Value::getValueId the value of this is 0x0.

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