forked from OSchip/llvm-project
hwasan: Ignore loads and stores of size 0.
Now that memory intrinsics are instrumented, it's more likely that CheckAddressSized will be called with size 0. (It was possible before with IR like: %val = load [0 x i8], [0 x i8]* %ptr but I don't think clang will generate IR like that and the optimizer would normally remove it by the time it got anywhere near our pass anyway). The right thing to do in both cases is to disable the addressing checks (since the underlying memory intrinsic is a no-op), so that's what we do. Differential Revision: https://reviews.llvm.org/D56465 llvm-svn: 350683
This commit is contained in:
parent
243d0415c6
commit
fdef020d80
|
@ -61,7 +61,8 @@ __attribute__((always_inline, nodebug)) static void CheckAddress(uptr p) {
|
|||
template <ErrorAction EA, AccessType AT>
|
||||
__attribute__((always_inline, nodebug)) static void CheckAddressSized(uptr p,
|
||||
uptr sz) {
|
||||
CHECK_NE(0, sz);
|
||||
if (sz == 0)
|
||||
return;
|
||||
tag_t ptr_tag = GetTagFromPointer(p);
|
||||
uptr ptr_raw = p & ~kAddressTagMask;
|
||||
tag_t *shadow_first = (tag_t *)MemToShadow(ptr_raw);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// RUN: %clang_hwasan %s -o %t && %run %t
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
char a[1];
|
||||
memset(a, 0, 0);
|
||||
memmove(a, a, 0);
|
||||
memcpy(a, a, 0);
|
||||
}
|
Loading…
Reference in New Issue