Index: test/msan/Linux/aligned_alloc-alignment.cc =================================================================== --- test/msan/Linux/aligned_alloc-alignment.cc +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 -g %s -o %t -// RUN: MSAN_OPTIONS=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s -// RUN: MSAN_OPTIONS=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL - -// UNSUPPORTED: android - -// REQUIRES: stable-runtime - -#include -#include - -extern void *aligned_alloc(size_t alignment, size_t size); - -int main() { - void *p = aligned_alloc(17, 100); - // CHECK: ERROR: MemorySanitizer: invalid alignment requested in aligned_alloc: 17 - // Check just the top frame since mips is forced to use store_context_size==1 - // and also handle a case when aligned_alloc is aliased by memalign. - // CHECK: {{#0 0x.* in .*}}{{aligned_alloc|memalign}} - // CHECK: SUMMARY: MemorySanitizer: invalid-aligned-alloc-alignment - - printf("pointer after failed aligned_alloc: %zd\n", (size_t)p); - // CHECK-NULL: pointer after failed aligned_alloc: 0 - - return 0; -} Index: test/msan/posix_memalign-alignment.cc =================================================================== --- test/msan/posix_memalign-alignment.cc +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 -g %s -o %t -// RUN: MSAN_OPTIONS=$MSAN_OPTIONS:allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s -// RUN: MSAN_OPTIONS=$MSAN_OPTIONS:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL - -// REQUIRES: stable-runtime - -#include -#include - -int main() { - void *p = reinterpret_cast(42); - int res = posix_memalign(&p, 17, 100); - // CHECK: ERROR: MemorySanitizer: invalid alignment requested in posix_memalign: 17 - // Check just the top frame since mips is forced to use store_context_size==1 - // CHECK: {{#0 0x.* in .*posix_memalign}} - // CHECK: SUMMARY: MemorySanitizer: invalid-posix-memalign-alignment - - printf("pointer after failed posix_memalign: %zd\n", (size_t)p); - // CHECK-NULL: pointer after failed posix_memalign: 42 - - return 0; -} Index: test/sanitizer_common/TestCases/Linux/aligned_alloc-alignment.cc =================================================================== --- test/sanitizer_common/TestCases/Linux/aligned_alloc-alignment.cc +++ test/sanitizer_common/TestCases/Linux/aligned_alloc-alignment.cc @@ -1,13 +1,13 @@ -// RUN: %clangxx -O0 %s -o %t +// RUN: %clangxx %collect_stack_traces -O0 %s -o %t // RUN: %env_tool_opts=allocator_may_return_null=0 not %run %t 17 2>&1 | FileCheck %s // RUN: %env_tool_opts=allocator_may_return_null=0 not %run %t 0 2>&1 | FileCheck %s // RUN: %env_tool_opts=allocator_may_return_null=1 %run %t 17 2>&1 | FileCheck %s --check-prefix=CHECK-NULL // RUN: %env_tool_opts=allocator_may_return_null=1 %run %t 0 2>&1 | FileCheck %s --check-prefix=CHECK-NULL -// UNSUPPORTED: android, msan, tsan, ubsan - // REQUIRES: stable-runtime +// UNSUPPORTED: android, tsan, ubsan + #include #include #include Index: test/sanitizer_common/TestCases/Posix/posix_memalign-alignment.cc =================================================================== --- test/sanitizer_common/TestCases/Posix/posix_memalign-alignment.cc +++ test/sanitizer_common/TestCases/Posix/posix_memalign-alignment.cc @@ -1,4 +1,4 @@ -// RUN: %clangxx -O0 %s -o %t +// RUN: %clangxx %collect_stack_traces -O0 %s -o %t // RUN: %env_tool_opts=allocator_may_return_null=0 not %run %t 17 2>&1 | FileCheck %s // RUN: %env_tool_opts=allocator_may_return_null=0 not %run %t 0 2>&1 | FileCheck %s // RUN: %env_tool_opts=allocator_may_return_null=1 %run %t 17 2>&1 | FileCheck %s --check-prefix=CHECK-NULL @@ -6,7 +6,7 @@ // REQUIRES: stable-runtime -// UNSUPPORTED: msan, tsan, ubsan +// UNSUPPORTED: tsan, ubsan #include #include Index: test/sanitizer_common/lit.common.cfg =================================================================== --- test/sanitizer_common/lit.common.cfg +++ test/sanitizer_common/lit.common.cfg @@ -6,6 +6,7 @@ config.name = "SanitizerCommon-" + config.name_suffix default_tool_options = [] +collect_stack_traces = "" if config.tool_name == "asan": tool_cflags = ["-fsanitize=address"] tool_options = "ASAN_OPTIONS" @@ -15,6 +16,7 @@ elif config.tool_name == "msan": tool_cflags = ["-fsanitize=memory"] tool_options = "MSAN_OPTIONS" + collect_stack_traces = "-fsanitize-memory-track-origins" elif config.tool_name == "lsan": tool_cflags = ["-fsanitize=leak"] tool_options = "LSAN_OPTIONS" @@ -52,6 +54,7 @@ config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) ) config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) ) +config.substitutions.append( ("%collect_stack_traces", collect_stack_traces) ) config.substitutions.append( ("%tool_name", config.tool_name) ) config.substitutions.append( ("%tool_options", tool_options) ) config.substitutions.append( ('%env_tool_opts=',