<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Segmentation fault in DwarfDebug.cpp"
href="http://llvm.org/bugs/show_bug.cgi?id=22792">22792</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Segmentation fault in DwarfDebug.cpp
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>peter@pcc.me.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>~/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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>