[llvm-commits] [compiler-rt] r160719 - in /compiler-rt/trunk/lib/asan: asan_rtl.cc tests/asan_noinst_test.cc
Kostya Serebryany
kcc at google.com
Wed Jul 25 03:56:09 PDT 2012
Author: kcc
Date: Wed Jul 25 05:56:09 2012
New Revision: 160719
URL: http://llvm.org/viewvc/llvm-project?rev=160719&view=rev
Log:
[asan] don't return from a never-return function. fix a test that had a chain of bugs instead of just one
Modified:
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=160719&r1=160718&r2=160719&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed Jul 25 05:56:09 2012
@@ -387,9 +387,15 @@
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");
Modified: compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc?rev=160719&r1=160718&r2=160719&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_noinst_test.cc Wed Jul 25 05:56:09 2012
@@ -670,20 +670,12 @@
}
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);
}
More information about the llvm-commits
mailing list