brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 7ad0ff0 Raw
55 lines · cpp
1// RUN: %clangxx %s -fsanitize-memory-track-origins=1 -o %t2// 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=COMPRESS4// RUN: %env_tool_opts="compress_stack_depot=-2:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --check-prefixes=COMPRESS5// RUN: %env_tool_opts="compress_stack_depot=1:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --check-prefixes=COMPRESS,THREAD6// RUN: %env_tool_opts="compress_stack_depot=2:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --check-prefixes=COMPRESS,THREAD7 8// Ubsan does not store stacks.9// UNSUPPORTED: ubsan10 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{{.*}} && asan16 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 24std::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  else37    a(v);38}39 40__attribute__((noinline)) void b(unsigned v) { return a(v); }41 42int 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 started53// COMPRESS: StackDepot released {{[0-9]+}}54// THREAD: StackDepot compression thread stopped55