[compiler-rt] 116b5e1 - [test][sanitizer] Pre-commit huge malloc test

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 21 16:20:19 PDT 2023


Author: Vitaly Buka
Date: 2023-06-21T16:20:02-07:00
New Revision: 116b5e1eb44c284e17f178194cdeff51a0d970c6

URL: https://github.com/llvm/llvm-project/commit/116b5e1eb44c284e17f178194cdeff51a0d970c6
DIFF: https://github.com/llvm/llvm-project/commit/116b5e1eb44c284e17f178194cdeff51a0d970c6.diff

LOG: [test][sanitizer] Pre-commit huge malloc test

Added: 
    compiler-rt/test/sanitizer_common/TestCases/Posix/huge_malloc.c

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/huge_malloc.c b/compiler-rt/test/sanitizer_common/TestCases/Posix/huge_malloc.c
new file mode 100644
index 0000000000000..df0e52aa2e2f3
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/huge_malloc.c
@@ -0,0 +1,24 @@
+// RUN: %clang -O0 %s -o %t && %env_tool_opts=allocator_may_return_null=1:hard_rss_limit_mb=50 %run %t
+
+#include <stdlib.h>
+#include <stdio.h>
+
+// FIXME: Hangs.
+// UNSUPPORTED: tsan
+
+// https://github.com/google/sanitizers/issues/981
+// UNSUPPORTED: android-26
+
+// FIXME: Make it work. Don't xfail to avoid excessive memory usage.
+// UNSUPPORTED: asan, msan, hwasan
+
+void* p;
+
+int main(int argc, char **argv) {
+  for (int i = 0; i < sizeof(void*) * 8; ++i) {
+    p = malloc(1ull << i);
+    printf("%llu: %p\n", (1ull << i), p);
+    free(p);
+  }
+  return 0;
+}


        


More information about the llvm-commits mailing list