xref: /llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/huge_malloc.c (revision 81ff4d6f2e45d42060992f724ec305c507f31505)
1 // RUN: %clang -O0 %s -o %t && %env_tool_opts=allocator_may_return_null=1:hard_rss_limit_mb=50:quarantine_size_mb=1 %run %t
2 
3 #include <stdlib.h>
4 #include <stdio.h>
5 
6 // https://github.com/google/sanitizers/issues/981
7 // UNSUPPORTED: android-26
8 
9 // FIXME: Hangs.
10 // UNSUPPORTED: tsan
11 
12 // Hwasan requires tagging of new allocations, so needs RSS for shadow.
13 // UNSUPPORTED: hwasan
14 
15 // FIXME: Something wrong with MADV_FREE or MAP_NORESERVE there.
16 // UNSUPPORTED: target={{.*solaris.*}}
17 
18 void *p;
19 
main(int argc,char ** argv)20 int main(int argc, char **argv) {
21   for (int i = 0; i < sizeof(void *) * 8; ++i) {
22     // Calloc avoids MSAN shadow poisoning.
23     p = calloc(1ull << i, 1);
24     fprintf(stderr, "%d %llu: %p\n", i, (1ull << i), p);
25     free(p);
26   }
27   return 0;
28 }
29