[compiler-rt] r258413 - [MSan] Add a test case for r258339.
Alexey Samsonov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 21 09:51:08 PST 2016
Author: samsonov
Date: Thu Jan 21 11:51:08 2016
New Revision: 258413
URL: http://llvm.org/viewvc/llvm-project?rev=258413&view=rev
Log:
[MSan] Add a test case for r258339.
Modified:
compiler-rt/trunk/test/sanitizer_common/TestCases/malloc_hook.cc
Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/malloc_hook.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/malloc_hook.cc?rev=258413&r1=258412&r2=258413&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/malloc_hook.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/malloc_hook.cc Thu Jan 21 11:51:08 2016
@@ -13,7 +13,7 @@ const volatile void *global_ptr;
// Note: avoid calling functions that allocate memory in malloc/free
// to avoid infinite recursion.
void __sanitizer_malloc_hook(const volatile void *ptr, size_t sz) {
- if (__sanitizer_get_ownership(ptr)) {
+ if (__sanitizer_get_ownership(ptr) && sz == 4) {
write(1, "MallocHook\n", sizeof("MallocHook\n"));
global_ptr = ptr;
}
@@ -24,8 +24,18 @@ void __sanitizer_free_hook(const volatil
}
} // extern "C"
+volatile int *x;
+
+// Call this function with uninitialized arguments to poison
+// TLS shadow for function parameters before calling operator
+// new and, eventually, user-provided hook.
+__attribute__((noinline)) void allocate(int *unused1, int *unused2) {
+ x = new int;
+}
+
int main() {
- volatile int *x = new int;
+ int *undef1, *undef2;
+ allocate(undef1, undef2);
// CHECK: MallocHook
// Check that malloc hook was called with correct argument.
if (global_ptr != (void*)x) {
More information about the llvm-commits
mailing list