[LLVMbugs] [Bug 22792] New: Segmentation fault in DwarfDebug.cpp
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Mar 4 10:37:02 PST 2015
http://llvm.org/bugs/show_bug.cgi?id=22792
Bug ID: 22792
Summary: Segmentation fault in DwarfDebug.cpp
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: peter at pcc.me.uk
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
~/src/llvm$ git diff
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 1cc0581..ef07624 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -367,6 +367,7 @@ void
DwarfDebug::constructAbstractSubprogramScopeDIE(LexicalScope *Scope) {
// Find the subprogram's DwarfCompileUnit in the SPMap in case the
subprogram
// was inlined from another compile unit.
auto &CU = SPMap[SP];
+ assert(CU && "expected CU");
forBothCUs(*CU, [&](DwarfCompileUnit &CU) {
CU.constructAbstractSubprogramScopeDIE(Scope);
});
$ cat 1.cc
namespace std {
template <class> class A;
namespace priv {
template <class _Value> class B {
public:
_Value _M_data;
B(int, _Value);
};
}
template <class _CharT, class, class = A<_CharT>> class basic_string;
template <class _InputIter, class _ForwardIter>
void uninitialized_copy(_InputIter, _ForwardIter);
namespace priv {
template <class _Tp> class C {
public:
enum { _DEFAULT_SIZE = 4 * sizeof(void *) };
typedef int size_type;
union {
_Tp *_M_end_of_storage;
_Tp _M_static_buf[_DEFAULT_SIZE];
} _M_buffers;
_Tp _M_Start();
_Tp *_M_finish;
B<_Tp *> _M_start_of_storage;
void _M_allocate_block(unsigned);
C(int p1) : _M_start_of_storage(p1, _M_buffers._M_static_buf) {}
};
}
template <class _CharT, class, class> class basic_string : priv::C<_CharT> {
public:
basic_string();
basic_string(_CharT *p1, typename priv::C<_CharT>::size_type p2,
int p3 = int())
: priv::C<_CharT>(p3) {
_M_range_initialize(p1, p1 + p2);
}
void _M_range_initialize(const _CharT *p1, const _CharT *p2) {
short b;
int c = p2 - p1;
this->_M_allocate_block(c + 1);
b = this->_M_Start();
uninitialized_copy(p2, b);
}
_CharT *c_str();
};
}
extern template class std::basic_string<unsigned short, int>;
template <typename STRING_TYPE> class D {
public:
D(STRING_TYPE);
int size();
STRING_TYPE
as_string() { return STRING_TYPE(0, size()); }
};
struct F {
typedef std::basic_string<unsigned short, int> Head;
typedef int Tail;
};
struct G {
typedef std::basic_string<int, std::A<char>> Head;
typedef F Tail;
};
template <template <typename> class Tmpl> struct H {
template <typename T> struct I { typedef Tmpl<T> type; };
};
class J;
typedef void *TypeId;
class K {};
template <class TestClass> class N : public K {
virtual J *CreateTest() { return new TestClass; }
};
template <class TestSel, typename Types> class L {
public:
static bool Register(const char *p1, const char *p2, const char *p3, int) {
TypeId d;
typedef typename TestSel::template I<typename Types::Head>::type TestClass;
d = 0;
MakeAndRegisterTestInfo(d, new N<TestClass>);
return L<TestSel, typename Types::Tail>::Register(p1, p2, p3, 1);
}
};
template <class TestSel> class L<TestSel, int> {
public:
static bool Register(const char *, const char *, const char *, int);
};
class J {};
template <typename gtest_TypeParam_> class O : public J {
typedef gtest_TypeParam_ TypeParam;
virtual void TestBody();
};
bool e = L<H<O>, G>::Register("", "", "", 0);
void MakeAndRegisterTestInfo(TypeId, K *);
template <typename gtest_TypeParam_> void O<gtest_TypeParam_>::TestBody() {
TypeParam f;
D<TypeParam> a(f);
TypeParam(a.as_string().c_str(), 7);
}
$ cat 2.cc
namespace std {
template <class> class A;
template <class _Value, class, class> class M { _Value _M_data; };
template <class _CharT, class, class = A<_CharT>> class basic_string;
namespace priv {
template <class _Tp, class _Alloc> class _String_base {
enum { _DEFAULT_SIZE = 4 * sizeof(void *) };
typedef _Alloc allocator_type;
typedef M<_Tp *, _Tp, allocator_type> _AllocProxy;
union {
_Tp *_M_end_of_storage;
_Tp _M_static_buf[_DEFAULT_SIZE];
};
_Tp *_M_finish;
_AllocProxy _M_start_of_storage;
};
}
template <class _CharT, class, class _Alloc>
class basic_string : priv::_String_base<_CharT, _Alloc> {
void _M_range_initialize(const _CharT *, const _CharT *) {}
};
}
template class std::basic_string<unsigned short, int>;
$ ~/src/llvm-build-rasserts/bin/clang++ -std=gnu++11 -flto -g -Os -c -o 1.o
1.cc
$ ~/src/llvm-build-rasserts/bin/clang++ -std=gnu++11 -flto -g -Os -c -o 2.o
2.cc
$ ~/src/llvm-build-rasserts/bin/llvm-lto -o /dev/null 1.o 2.o
llvm-lto: .../llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:370: void
llvm::DwarfDebug::constructAbstractSubprogramScopeDIE(llvm::LexicalScope *):
Assertion `CU && "expected CU"' failed.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150304/91959785/attachment.html>
More information about the llvm-bugs
mailing list