[compiler-rt] [libcxx] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (PR #143230)

Daniil Kovalev via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 6 09:12:42 PDT 2025


================
@@ -90,6 +90,18 @@
   } while (0)
 #endif
 
+// There is not currently a clean way to cast between an authenticated
+// integer and an authenticated function pointer, so we need this helper
+// function to keep things clean.
+static _Unwind_Personality_Fn get_handler_function(unw_proc_info_t *frameInfo) {
+  union {
+    void *opaque_handler;
+    _Unwind_Personality_Fn __ptrauth_unwind_upi_handler *handler;
+  } u;
+  u.opaque_handler = (void *)&frameInfo->handler;
+  return *u.handler;
----------------
kovdan01 wrote:

While this should be valid in C, in C++ reading from the member of the union that wasn't most recently written is technically UB: https://en.cppreference.com/w/cpp/language/union.html.

I think we need to conform to C++ standard and use smth like `memcpy` for doing such a trick.

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


More information about the llvm-commits mailing list