From d8282087136cce39f629ba131a67ccb162b094b0 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Mon, 28 Oct 2013 18:53:37 +0000 Subject: [PATCH] [msan] Fix a typo and enable poison_in_free flag. llvm-svn: 193529 --- compiler-rt/lib/msan/lit_tests/poison_in_free.cc | 16 ++++++++++++++++ compiler-rt/lib/msan/msan.cc | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 compiler-rt/lib/msan/lit_tests/poison_in_free.cc diff --git a/compiler-rt/lib/msan/lit_tests/poison_in_free.cc b/compiler-rt/lib/msan/lit_tests/poison_in_free.cc new file mode 100644 index 000000000000..f134d05abb1e --- /dev/null +++ b/compiler-rt/lib/msan/lit_tests/poison_in_free.cc @@ -0,0 +1,16 @@ +// RUN: %clangxx_msan -O0 %s -o %t && not %t >%t.out 2>&1 +// FileCheck %s <%t.out +// RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=poison_in_free=0 %t >%t.out 2>&1 + +#include +#include +#include + +int main(int argc, char **argv) { + char *volatile x = (char*)malloc(50 * sizeof(char)); + memset(x, 0, 50); + free(x); + return x[25]; + // CHECK: MemorySanitizer: use-of-uninitialized-value + // CHECK: #0 {{.*}} in main{{.*}}poison_in_free.cc:[[@LINE-2]] +} diff --git a/compiler-rt/lib/msan/msan.cc b/compiler-rt/lib/msan/msan.cc index 7865044c4f1f..9238431543a0 100644 --- a/compiler-rt/lib/msan/msan.cc +++ b/compiler-rt/lib/msan/msan.cc @@ -122,7 +122,7 @@ static void ParseFlagsFromString(Flags *f, const char *str) { ParseFlag(str, &f->poison_heap_with_zeroes, "poison_heap_with_zeroes"); ParseFlag(str, &f->poison_stack_with_zeroes, "poison_stack_with_zeroes"); ParseFlag(str, &f->poison_in_malloc, "poison_in_malloc"); - ParseFlag(str, &f->poison_in_malloc, "poison_in_free"); + ParseFlag(str, &f->poison_in_free, "poison_in_free"); ParseFlag(str, &f->exit_code, "exit_code"); if (f->exit_code < 0 || f->exit_code > 127) { Printf("Exit code not in [0, 128) range: %d\n", f->exit_code);