[llvm-bugs] [Bug 32630] New: UBSan: No warning for misaligned load of extern
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Apr 11 12:19:35 PDT 2017
http://bugs.llvm.org/show_bug.cgi?id=32630
Bug ID: 32630
Summary: UBSan: No warning for misaligned load of extern
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: vsk at apple.com
CC: llvm-bugs at lists.llvm.org
Presently, UBSan does not diagnose misaligned loads/stores from extern
variables. Example:
// a.c
struct S { int I; }
extern S global_S;
int getI() { return global_S.I; }
// b.c
char ...;
char global_S[4];
char ...;
UBSan can emit an alignment check for loads from DeclRefExprs. However, this
isn't enough to catch the issue, because the IRBuilder constant folds the
alignment test away to 'true': (and (ptrtoint (gep &global_S ...)) 3) => 0.
This makes the test ineffective.
We might try and fix this by disabling constant folding when emitting UBSan
checks.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170411/9f13cc05/attachment.html>
More information about the llvm-bugs
mailing list