diff options
author | Kostya Serebryany <kcc@google.com> | 2012-07-25 10:56:09 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2012-07-25 10:56:09 +0000 |
commit | bb0ade6daa621b300ba68e736dcd19cd3c3bcc71 (patch) | |
tree | 00e34b3028a39b39520e74ab10a1a8dc4eb4c8c1 | |
parent | c145b026072a9eb7d62cb726c90b8f40e8194ecd (diff) | |
download | bcm5719-llvm-bb0ade6daa621b300ba68e736dcd19cd3c3bcc71.tar.gz bcm5719-llvm-bb0ade6daa621b300ba68e736dcd19cd3c3bcc71.zip |
[asan] don't return from a never-return function. fix a test that had a chain of bugs instead of just one
llvm-svn: 160719
-rw-r--r-- | compiler-rt/lib/asan/asan_rtl.cc | 10 | ||||
-rw-r--r-- | compiler-rt/lib/asan/tests/asan_noinst_test.cc | 12 |
2 files changed, 10 insertions, 12 deletions
diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index 5e6e8154718..34324fa16d0 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -387,9 +387,15 @@ void NOINLINE __asan_set_error_report_callback(void (*callback)(const char*)) { void __asan_report_error(uptr pc, uptr bp, uptr sp, uptr addr, bool is_write, uptr access_size) { - // Do not print more than one report, otherwise they will mix up. static atomic_uint32_t num_calls; - if (atomic_fetch_add(&num_calls, 1, memory_order_relaxed) != 0) return; + if (atomic_fetch_add(&num_calls, 1, memory_order_relaxed) != 0) { + // Do not print more than one report, otherwise they will mix up. + // We can not return here because the function is marked as never-return. + AsanPrintf("AddressSanitizer: while reporting a bug found another one." + "Ignoring.\n"); + SleepForSeconds(5); + Die(); + } AsanPrintf("====================================================" "=============\n"); diff --git a/compiler-rt/lib/asan/tests/asan_noinst_test.cc b/compiler-rt/lib/asan/tests/asan_noinst_test.cc index 8c3d126090a..44d4c3c845b 100644 --- a/compiler-rt/lib/asan/tests/asan_noinst_test.cc +++ b/compiler-rt/lib/asan/tests/asan_noinst_test.cc @@ -670,20 +670,12 @@ TEST(AddressSanitizerInterface, DISABLED_InvalidPoisonAndUnpoisonCallsTest) { } static void ErrorReportCallbackOneToZ(const char *report) { - int len = strlen(report); - char *dup = (char*)malloc(len); - strcpy(dup, report); - for (int i = 0; i < len; i++) { - if (dup[i] == '1') dup[i] = 'Z'; - } - int written = write(2, dup, len); - ASSERT_EQ(len, written); - free(dup); + write(2, "ABCDEF", 6); } TEST(AddressSanitizerInterface, SetErrorReportCallbackTest) { __asan_set_error_report_callback(ErrorReportCallbackOneToZ); - EXPECT_DEATH(__asan_report_error(0, 0, 0, 0, true, 1), "size Z"); + EXPECT_DEATH(__asan_report_error(0, 0, 0, 0, true, 1), "ABCDEF"); __asan_set_error_report_callback(NULL); } |