summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2016-01-21 17:51:08 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2016-01-21 17:51:08 +0000
commitc8adcb4af6131ecc427f128a208272c1eff2fc2b (patch)
treee01c8bfca21839a7168ff1534f159f3b81d63357 /compiler-rt
parentf3ee254bc2b63f0743d83776a8a3420818f5f906 (diff)
downloadbcm5719-llvm-c8adcb4af6131ecc427f128a208272c1eff2fc2b.tar.gz
bcm5719-llvm-c8adcb4af6131ecc427f128a208272c1eff2fc2b.zip
[MSan] Add a test case for r258339.
llvm-svn: 258413
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/test/sanitizer_common/TestCases/malloc_hook.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler-rt/test/sanitizer_common/TestCases/malloc_hook.cc b/compiler-rt/test/sanitizer_common/TestCases/malloc_hook.cc
index 9702249c57e..7a45f8dfb23 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/malloc_hook.cc
+++ b/compiler-rt/test/sanitizer_common/TestCases/malloc_hook.cc
@@ -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 volatile void *ptr) {
}
} // 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) {
OpenPOWER on IntegriCloud