xref: /aosp_15_r20/external/compiler-rt/test/tsan/Darwin/malloc-stack-logging.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // Test that MallocStackLogging=1 doesn't crash. MallocStackLogging turns on
2*7c3d14c8STreehugger Robot // callbacks from mmap/munmap libc function into libmalloc. Darwin-specific
3*7c3d14c8STreehugger Robot // ThreadState initialization needs to avoid calling the library functions (and
4*7c3d14c8STreehugger Robot // use syscalls directly) to make sure other interceptors aren't called.
5*7c3d14c8STreehugger Robot 
6*7c3d14c8STreehugger Robot // RUN: %clangxx_tsan -O1 %s -o %t
7*7c3d14c8STreehugger Robot // RUN: MallocStackLogging=1 %run %t 2>&1 | FileCheck %s
8*7c3d14c8STreehugger Robot #include <pthread.h>
9*7c3d14c8STreehugger Robot #include <stdlib.h>
10*7c3d14c8STreehugger Robot #include <stdio.h>
11*7c3d14c8STreehugger Robot 
foo(void * p)12*7c3d14c8STreehugger Robot void *foo(void *p) {
13*7c3d14c8STreehugger Robot     return NULL;
14*7c3d14c8STreehugger Robot }
15*7c3d14c8STreehugger Robot 
main()16*7c3d14c8STreehugger Robot int main() {
17*7c3d14c8STreehugger Robot     pthread_t t;
18*7c3d14c8STreehugger Robot     pthread_create(&t, NULL, foo, NULL);
19*7c3d14c8STreehugger Robot     pthread_join(t, NULL);
20*7c3d14c8STreehugger Robot     fprintf(stderr, "Done.\n");
21*7c3d14c8STreehugger Robot     return 0;
22*7c3d14c8STreehugger Robot }
23*7c3d14c8STreehugger Robot 
24*7c3d14c8STreehugger Robot // CHECK: Done.
25