<div dir="ltr">+Richard<div><br></div><div>Note, that you'd also have to update comment for VtablePrefix::Offset field.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 11, 2014 at 6:30 AM, Stephan Bergmann <span dir="ltr"><<a href="mailto:sbergman@redhat.com" target="_blank">sbergman@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">At least with recent Clang trunk on Linux x86_64:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
$ cat test.cc<br>
#include <iostream><br>
struct A { virtual ~A() {} };<br>
struct B: virtual A {};<br>
struct C: virtual A { ~C() { std::cout << '\n'; } };<br>
struct D: virtual B, virtual C {};<br>
int main() { delete new D; }<br>
<br>
$ clang++ -fsanitize=undefined test.cc<br>
<br>
$ ./a.out<br>
<unknown>: runtime error: member call on address 0x000002a35010 which does not point to an object of type 'A'<br>
0x000002a35010: note: object has invalid vptr<br>
 00 00 00 00  58 0e 43 00 00 00 00 00  30 0e 43 00 00 00 00 00  00 00 00 00 00 00 00 00  e1 0f 02 00<br>
              ^~~~~~~~~~~~~~~~~~~~~~~<br>
              invalid vptr<br>
</blockquote>
<br>
The problem is that getVtablePrefix (lib/ubsan/ubsan_type_hash.cc) rejects any VtablePrefix with Offset > 0 as "This can't possibly be a valid vtable" but, according to the Itanium ABI, "in some construction virtual tables will some virtual base virtual tables have positive offsets."<br>

<br>
The apparent fix is to remove the check, see the attached getVtablePrefix.patch.<span class="HOEnZb"><font color="#888888"><br>
<br>
Stephan<br>
</font></span><br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div>
</div>