diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2013-09-27 02:31:23 +0000 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2013-09-27 02:31:23 +0000 |
| commit | 439a90451554ed11ee51ed53debf6037e10ef7db (patch) | |
| tree | 159ffa1765e1040a6c0b35bdac860e2630707b75 | |
| parent | 4467f33e3c397a6cf67258243fbddc53178c6ce8 (diff) | |
| download | bcm5719-llvm-439a90451554ed11ee51ed53debf6037e10ef7db.tar.gz bcm5719-llvm-439a90451554ed11ee51ed53debf6037e10ef7db.zip | |
tsan: support allocator_may_return_null flag
Fixes https://code.google.com/p/thread-sanitizer/issues/detail?id=29
llvm-svn: 191482
| -rw-r--r-- | compiler-rt/lib/tsan/lit_tests/malloc_overflow.cc | 2 | ||||
| -rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_flags.cc | 4 | ||||
| -rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_flags.h | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/compiler-rt/lib/tsan/lit_tests/malloc_overflow.cc b/compiler-rt/lib/tsan/lit_tests/malloc_overflow.cc index 8fd12dff1d0..afbebc8bec4 100644 --- a/compiler-rt/lib/tsan/lit_tests/malloc_overflow.cc +++ b/compiler-rt/lib/tsan/lit_tests/malloc_overflow.cc @@ -1,5 +1,3 @@ -// XFAIL: * -// FIXME: https://code.google.com/p/thread-sanitizer/issues/detail?id=29 // RUN: %clangxx_tsan -O1 %s -o %t // RUN: TSAN_OPTIONS=allocator_may_return_null=1 %t 2>&1 | FileCheck %s #include <stdio.h> diff --git a/compiler-rt/lib/tsan/rtl/tsan_flags.cc b/compiler-rt/lib/tsan/rtl/tsan_flags.cc index 86e45f6457f..a1f82004074 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_flags.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_flags.cc @@ -64,6 +64,7 @@ void InitializeFlags(Flags *f, const char *env) { f->external_symbolizer_path = ""; f->history_size = kGoMode ? 1 : 2; // There are a lot of goroutines in Go. f->io_sync = 1; + f->allocator_may_return_null = false; // Let a frontend override. OverrideFlags(f); @@ -95,6 +96,7 @@ void InitializeFlags(Flags *f, const char *env) { ParseFlag(env, &f->external_symbolizer_path, "external_symbolizer_path"); ParseFlag(env, &f->history_size, "history_size"); ParseFlag(env, &f->io_sync, "io_sync"); + ParseFlag(env, &f->allocator_may_return_null, "allocator_may_return_null"); if (!f->report_bugs) { f->report_thread_leaks = false; @@ -113,6 +115,8 @@ void InitializeFlags(Flags *f, const char *env) { " (must be [0..2])\n"); Die(); } + + common_flags()->allocator_may_return_null = f->allocator_may_return_null; } } // namespace __tsan diff --git a/compiler-rt/lib/tsan/rtl/tsan_flags.h b/compiler-rt/lib/tsan/rtl/tsan_flags.h index b517ccc3ffa..238982bf2a3 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_flags.h +++ b/compiler-rt/lib/tsan/rtl/tsan_flags.h @@ -92,6 +92,8 @@ struct Flags { // 1 - reasonable level of synchronization (write->read) // 2 - global synchronization of all IO operations int io_sync; + // If false, the allocator will crash instead of returning 0 on out-of-memory. + bool allocator_may_return_null; }; Flags *flags(); |

