| 1 |
// RUN: %clangxx %s -fsanitize-memory-track-origins=1 -o %t |
| 2 |
// RUN: %env_tool_opts="compress_stack_depot=0:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --implicit-check-not="StackDepot released" |
| 3 |
// RUN: %env_tool_opts="compress_stack_depot=-1:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --check-prefixes=COMPRESS |
| 4 |
// RUN: %env_tool_opts="compress_stack_depot=-2:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --check-prefixes=COMPRESS |
| 5 |
// RUN: %env_tool_opts="compress_stack_depot=1:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --check-prefixes=COMPRESS,THREAD |
| 6 |
// RUN: %env_tool_opts="compress_stack_depot=2:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --check-prefixes=COMPRESS,THREAD |
| 7 |
|
| 8 |
// Ubsan does not store stacks. |
| 9 |
// UNSUPPORTED: ubsan |
| 10 |
|
| 11 |
// FIXME: Fails for unknown reason. |
| 12 |
// UNSUPPORTED: target=s390x{{.*}} |
| 13 |
|
| 14 |
// Similar to D114934, something is broken with background thread on THUMB and Asan. |
| 15 |
// XFAIL: target=thumb{{.*}} && asan |
| 16 |
|
| 17 |
#include <sanitizer/common_interface_defs.h> |
| 18 |
|
| 19 |
#include <memory> |
| 20 |
|
| 21 |
__attribute__((noinline)) void a(unsigned v); |
| 22 |
__attribute__((noinline)) void b(unsigned v); |
| 23 |
|
| 24 |
std::unique_ptr<int[]> p; |
| 25 |
|
| 26 |
__attribute__((noinline)) void a(unsigned v) { |
| 27 |
int x; |
| 28 |
v >>= 1; |
| 29 |
if (!v) { |
| 30 |
p.reset(new int[100]); |
| 31 |
p[1] = x; |
| 32 |
return; |
| 33 |
} |
| 34 |
if (v & 1) |
| 35 |
b(v); |
| 36 |
else |
| 37 |
a(v); |
| 38 |
} |
| 39 |
|
| 40 |
__attribute__((noinline)) void b(unsigned v) { return a(v); } |
| 41 |
|
| 42 |
int main(int argc, char *argv[]) { |
| 43 |
for (unsigned i = 0; i < 100000; ++i) |
| 44 |
a(i + (i << 16)); |
| 45 |
|
| 46 |
__sanitizer_sandbox_arguments args = {0}; |
| 47 |
__sanitizer_sandbox_on_notify(&args); |
| 48 |
|
| 49 |
return 0; |
| 50 |
} |
| 51 |
|
| 52 |
// THREAD: StackDepot compression thread started |
| 53 |
// COMPRESS: StackDepot released {{[0-9]+}} |
| 54 |
// THREAD: StackDepot compression thread stopped |