[PATCH] D92001: [ubsan] Fix crash on __builtin_assume_aligned

Orivej Desh via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 23 21:27:20 PST 2020


orivej created this revision.
orivej added reviewers: lebedev.ri, Tyker, rsmith.
orivej added projects: clang, Sanitizers.
Herald added a subscriber: cfe-commits.
orivej requested review of this revision.

Fixes PR45813


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92001

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/ubsan-assume-aligned-crash.c


Index: clang/test/CodeGen/ubsan-assume-aligned-crash.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/ubsan-assume-aligned-crash.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsanitize=alignment -emit-llvm %s -o /dev/null
+
+/* Testcase for PR - clang crashes checking isVolatileQualified of isNull pointee. */
+
+__attribute__((aligned(8))) int data[2];
+
+int* test() {
+    return __builtin_assume_aligned(data, 8);
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2521,7 +2521,7 @@
 
   // Don't check pointers to volatile data. The behavior here is implementation-
   // defined.
-  if (Ty->getPointeeType().isVolatileQualified())
+  if (!Ty->getPointeeType().isNull() && Ty->getPointeeType().isVolatileQualified())
     return;
 
   // We need to temorairly remove the assumption so we can insert the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92001.307238.patch
Type: text/x-patch
Size: 1013 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201124/951d190d/attachment.bin>


More information about the cfe-commits mailing list