[PATCH] D148785: -fsanitize=function: use type hashes instead of RTTI objects

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 15 11:56:34 PDT 2023

MaskRay marked 2 inline comments as done.
MaskRay added a comment.

In D148785#4343112 <https://reviews.llvm.org/D148785#4343112>, @peter.smith wrote:

> Should `HANDLER(__ubsan_handle_function_type_mismatch,"function")` be added to ubsan_minimal_runtime if this is supported in the minimal runtime?

Thanks for the comments.

`compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp` has `HANDLER(function_type_mismatch, "function-type-mismatch")` and with this patch `clang++ -fsanitize=function -fsanitize-minimal-runtime` works.

Comment at: clang/lib/CodeGen/CGExpr.cpp:5382
+          getPointerAlign());
       llvm::Value *CalleeRTTIMatch =
+          Builder.CreateICmpEQ(CalleeTypeHash, TypeHash);
peter.smith wrote:
> Would CalleeTypeHashMatch be a better name?
Thanks for the suggestion. Adopted.

Comment at: clang/lib/CodeGen/CodeGenFunction.h:120
   SANITIZER_CHECK(FloatCastOverflow, float_cast_overflow, 0)                   \
-  SANITIZER_CHECK(FunctionTypeMismatch, function_type_mismatch, 1)             \
+  SANITIZER_CHECK(FunctionTypeMismatch, function_type_mismatch, 0)             \
   SANITIZER_CHECK(ImplicitConversion, implicit_conversion, 0)                  \
peter.smith wrote:
> Presumably the signature is different to the original v0 shouldn't it be 2; or is it effectively so long since the last one that we can reuse the original without fear?
The signature is identical to the original v0, so we just "downgrade" the version.

  rG LLVM Github Monorepo



More information about the llvm-commits mailing list