[PATCH] D46665: [Itanium] Emit type info names with external linkage.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 16 15:17:46 PDT 2018


rsmith added a comment.

This is causing ASan's ODR violation detector to fire. I think the problematic case looks like this:

TU 1:

  struct X;
  /*...*/ typeid(X*); /*...*/

TU 2:

  struct X { virtual void f(); };
  void X::f() {}

Now, TU 1 will emit a `linkonce_odr` definition of the `_ZTS` symbol, and TU 2 will emit a strong definition of it. ASan doesn't like that.

There's no way we can know that there will be a strong definition of the typeinfo name at the point where we emit the tentative copy for the pointer `type_info`. It seems to me there are two things we could do about this:

1. decide this is not a bug and suppress the ASan ODR checker report, or
2. decide this is a bug, and only emit `linkonce_odr` typeinfo names for pointers to incomplete classes, not for incomplete classes themselves (this would mean that `operator==` etc would do the wrong thing for users who use the <cxxabi.h> to inspect the pointee type of a pointer type info; in particular, we'd need to check that ubsan's vptr sanitizer can cope with this -- right now it assumes that it can compare the type name address except on iOS64, just like libc++'s `<type_info>` does).


Repository:
  rC Clang

https://reviews.llvm.org/D46665





More information about the cfe-commits mailing list