|
1 | | -// malloc: all bytes are uninitialized |
| 1 | +// *** malloc: all bytes are uninitialized |
| 2 | +// * malloc byte 0 |
| 3 | +// RUN: %clang_msan -fsanitize-memory-track-origins=1 %s -o %t && not %run %t 0 2>&1 \ |
| 4 | +// RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC |
2 | 5 | // RUN: %clang_msan -fsanitize-memory-track-origins=2 %s -o %t && not %run %t 0 2>&1 \ |
3 | 6 | // RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC |
| 7 | +// |
| 8 | +// * malloc byte 6 |
4 | 9 | // RUN: %clang_msan -fsanitize-memory-track-origins=2 %s -o %t && not %run %t 6 2>&1 \ |
5 | 10 | // RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC |
| 11 | +// RUN: %clang_msan -fsanitize-memory-track-origins=1 %s -o %t && not %run %t 6 2>&1 \ |
| 12 | +// RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC |
6 | 13 | // |
7 | 14 | // This test assumes the allocator allocates 16 bytes for malloc(7). Bytes |
8 | 15 | // 7-15 are padding. |
| 16 | +// |
| 17 | +// * malloc byte 7 |
9 | 18 | // Edge case: when the origin granularity spans both ALLOC and ALLOC_PADDING, |
10 | | -// ALLOC takes precedence |
| 19 | +// ALLOC always takes precedence. |
| 20 | +// RUN: %clang_msan -fsanitize-memory-track-origins=1 %s -o %t && not %run %t 7 2>&1 \ |
| 21 | +// RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC |
11 | 22 | // RUN: %clang_msan -fsanitize-memory-track-origins=2 %s -o %t && not %run %t 7 2>&1 \ |
12 | 23 | // RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC |
13 | 24 | // |
14 | | -// Bytes 8-15 are tagged as ALLOC_PADDING. |
| 25 | +// Bytes 8-15 are padding |
| 26 | +// For track-origins=1, ALLOC is used instead of ALLOC_PADDING. |
| 27 | +// |
| 28 | +// * malloc byte 8 |
| 29 | +// RUN: %clang_msan -fsanitize-memory-track-origins=1 %s -o %t && not %run %t 8 2>&1 \ |
| 30 | +// RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC |
15 | 31 | // RUN: %clang_msan -fsanitize-memory-track-origins=2 %s -o %t && not %run %t 8 2>&1 \ |
16 | 32 | // RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC-PADDING |
| 33 | +// |
| 34 | +// * malloc byte 15 |
| 35 | +// RUN: %clang_msan -fsanitize-memory-track-origins=1 %s -o %t && not %run %t 15 2>&1 \ |
| 36 | +// RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC |
17 | 37 | // RUN: %clang_msan -fsanitize-memory-track-origins=2 %s -o %t && not %run %t 15 2>&1 \ |
18 | 38 | // RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC-PADDING |
19 | 39 |
|
20 | | -// calloc |
| 40 | +// *** calloc |
21 | 41 | // Bytes 0-6 are fully initialized, so no MSan report should happen. |
| 42 | +// |
| 43 | +// * calloc byte 0 |
| 44 | +// RUN: %clang_msan -fsanitize-memory-track-origins=1 -DUSE_CALLOC %s -o %t && %run %t 0 2>&1 |
22 | 45 | // RUN: %clang_msan -fsanitize-memory-track-origins=2 -DUSE_CALLOC %s -o %t && %run %t 0 2>&1 |
| 46 | +// |
| 47 | +// * calloc byte 6 |
| 48 | +// RUN: %clang_msan -fsanitize-memory-track-origins=1 -DUSE_CALLOC %s -o %t && %run %t 6 2>&1 |
23 | 49 | // RUN: %clang_msan -fsanitize-memory-track-origins=2 -DUSE_CALLOC %s -o %t && %run %t 6 2>&1 |
24 | 50 | // |
| 51 | +// * calloc byte 7 |
25 | 52 | // Byte 7 is uninitialized. Unlike malloc, this is tagged as ALLOC_PADDING |
26 | 53 | // (since the origin does not need to track bytes 4-6). |
| 54 | +// RUN: %clang_msan -fsanitize-memory-track-origins=1 -DUSE_CALLOC %s -o %t && not %run %t 7 2>&1 \ |
| 55 | +// RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC-PADDING |
27 | 56 | // RUN: %clang_msan -fsanitize-memory-track-origins=2 -DUSE_CALLOC %s -o %t && not %run %t 7 2>&1 \ |
28 | 57 | // RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC-PADDING |
29 | 58 | // |
30 | | -// As with malloc, Bytes 8-15 are tagged as ALLOC_PADDING. |
| 59 | +// * calloc byte 8 |
| 60 | +// RUN: %clang_msan -fsanitize-memory-track-origins=1 -DUSE_CALLOC %s -o %t && not %run %t 8 2>&1 \ |
| 61 | +// RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC-PADDING |
31 | 62 | // RUN: %clang_msan -fsanitize-memory-track-origins=2 -DUSE_CALLOC %s -o %t && not %run %t 8 2>&1 \ |
32 | 63 | // RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC-PADDING |
| 64 | +// |
| 65 | +// * calloc byte 15 |
| 66 | +// RUN: %clang_msan -fsanitize-memory-track-origins=1 -DUSE_CALLOC %s -o %t && not %run %t 15 2>&1 \ |
| 67 | +// RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC-PADDING |
33 | 68 | // RUN: %clang_msan -fsanitize-memory-track-origins=2 -DUSE_CALLOC %s -o %t && not %run %t 15 2>&1 \ |
34 | 69 | // RUN: | FileCheck %s --check-prefixes=CHECK,ORIGIN-ALLOC-PADDING |
35 | 70 |
|
|
0 commit comments