[compiler-rt] [compiler-rt][ubsan][nfc-ish] Fix a type conversion bug (PR #100665)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 15:41:23 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Alan Zhao (alanzhao1)

<details>
<summary>Changes</summary>

With https://github.com/llvm/llvm-project/pull/100483, if the inline asm version of `ptrauth_strip` is used instead of the builtin, the inline asm implementation will return an unsigned long, causing an incompatible pointer conversion issue.

---
Full diff: https://github.com/llvm/llvm-project/pull/100665.diff


1 Files Affected:

- (modified) compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp (+2-1) 


``````````diff
diff --git a/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp b/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp
index 15788574dd995..7cc57268d40da 100644
--- a/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp
+++ b/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp
@@ -207,7 +207,8 @@ struct VtablePrefix {
   std::type_info *TypeInfo;
 };
 VtablePrefix *getVtablePrefix(void *Vtable) {
-  Vtable = ptrauth_strip(Vtable, ptrauth_key_cxx_vtable_pointer);
+  Vtable = reinterpret_cast<void *>(
+      ptrauth_strip(Vtable, ptrauth_key_cxx_vtable_pointer));
   VtablePrefix *Vptr = reinterpret_cast<VtablePrefix*>(Vtable);
   VtablePrefix *Prefix = Vptr - 1;
   if (!IsAccessibleMemoryRange((uptr)Prefix, sizeof(VtablePrefix)))

``````````

</details>


https://github.com/llvm/llvm-project/pull/100665


More information about the llvm-commits mailing list