[libcxx-commits] [PATCH] D97323: [libcxx] Fix infinite loop regression when building libc++ with ubsan

Nico Weber via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 23 12:00:12 PST 2021

thakis created this revision.
thakis added reviewers: rsmith, libc++.
thakis requested review of this revision.

made libcxxabi call typeinfo::operator==() in the implementation of
__dynamic_cast(). When ubsan instrumentation is active, it emits
a call to dynamic_cast<>() for the implementation of
typeinfo::operator== to verify the dynamic type of this. This leads
to infinite recursion.

As a workaround, disable ubsan instrumentation for

See https://crbug.com/1181057 for more notes.



Index: libcxx/include/typeinfo
--- libcxx/include/typeinfo
+++ libcxx/include/typeinfo
@@ -325,6 +325,13 @@
+#if __has_attribute(no_sanitize)
+     // libcxxabi's __dynamic_cast() implementation calls this operator to
+     // implement dynamic_cast<>(), but ubsan's instrumentation inserts a
+     // call to dynamic_cast<>() into the implementation of this function to
+     // check the dynamic type of |this|, leading to infinite recursion.
+     __attribute__((__no_sanitize__("undefined")))
     bool operator==(const type_info& __arg) const _NOEXCEPT
       return __impl::__eq(__type_name, __arg.__type_name);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97323.325864.patch
Type: text/x-patch
Size: 741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210223/439a3feb/attachment.bin>

More information about the libcxx-commits mailing list