[AA] Rename CaptureInfo -> CaptureAnalysis (NFC) (#116842)
[llvm-project.git] / compiler-rt / test / msan / release_origin.c
blobf056dab8b2b8b670d995523eda9896d9f877e068
1 // RUN: %clang_msan -fsanitize-memory-track-origins=0 -O0 %s -o %t && env MSAN_OPTIONS=soft_rss_limit_mb=18:verbosity=1:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s -implicit-check-not="soft rss limit" -check-prefixes=CHECK,NOORIG
2 // RUN: %clang_msan -fsanitize-memory-track-origins=2 -O0 %s -o %t && env MSAN_OPTIONS=soft_rss_limit_mb=36:verbosity=1:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s -implicit-check-not="soft rss limit" -check-prefixes=CHECK,ORIGIN
4 #include <assert.h>
5 #include <sanitizer/allocator_interface.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <unistd.h>
11 void *p;
13 int main(int argc, char **argv) {
14 int s = 20 * 1024 * 1024;
15 fprintf(stderr, "malloc\n");
16 p = malloc(s);
17 sleep(1);
18 fprintf(stderr, "memset\n");
19 memset(p, 1, s);
20 sleep(1);
21 fprintf(stderr, "free\n");
22 free(p);
23 sleep(1);
24 return 0;
27 // CHECK-LABEL: malloc
29 // Non origin mode allocate ~20M for shadow.
30 // Origin mode allocate ~20M for shadow and ~20M for origin.
31 // CHECK: soft rss limit exhausted
33 // CHECK-LABEL: memset
35 // Memset reserve modified pages, frees ~20M for shadow. So not change in RSS for non-origin mode.
36 // Origin mode also frees ~20M of origins, so 'unexhausted'.
37 // ORIGIN: soft rss limit unexhausted
39 // CHECK-LABEL: free
41 // Now non-origin release all everything.
42 // NOORIG: soft rss limit unexhausted