1 // RUN: %clangxx_msan -O2 %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s
7 int __msan_get_ownership(const void *p
);
11 // Note: avoid calling functions that allocate memory in malloc/free
12 // to avoid infinite recursion.
13 void __msan_malloc_hook(void *ptr
, size_t sz
) {
14 if (__msan_get_ownership(ptr
)) {
15 write(1, "MallocHook\n", sizeof("MallocHook\n"));
19 void __msan_free_hook(void *ptr
) {
20 if (__msan_get_ownership(ptr
) && ptr
== global_ptr
)
21 write(1, "FreeHook\n", sizeof("FreeHook\n"));
26 volatile int *x
= new int;
28 // Check that malloc hook was called with correct argument.
29 if (global_ptr
!= (void*)x
) {