Index: compiler-rt/lib/asan/asan_errors.h =================================================================== --- compiler-rt/lib/asan/asan_errors.h +++ compiler-rt/lib/asan/asan_errors.h @@ -27,19 +27,6 @@ u32 tid; }; -struct ErrorStackOverflow : ErrorBase { - SignalContext signal; - // VS2013 doesn't implement unrestricted unions, so we need a trivial default - // constructor - ErrorStackOverflow() = default; - ErrorStackOverflow(u32 tid, const SignalContext &sig) - : ErrorBase(tid), signal(sig) { - scariness.Clear(); - scariness.Scare(10, "stack-overflow"); - } - void Print(); -}; - struct ErrorDeadlySignal : ErrorBase { SignalContext signal; // VS2013 doesn't implement unrestricted unions, so we need a trivial default @@ -48,20 +35,20 @@ ErrorDeadlySignal(u32 tid, const SignalContext &sig) : ErrorBase(tid), signal(sig) { scariness.Clear(); - if (signal.is_memory_access) { - if (signal.addr < GetPageSizeCached()) { - scariness.Scare(10, "null-deref"); - } else if (signal.addr == signal.pc) { - scariness.Scare(60, "wild-jump"); - } else if (signal.write_flag == SignalContext::WRITE) { - scariness.Scare(30, "wild-addr-write"); - } else if (signal.write_flag == SignalContext::READ) { - scariness.Scare(20, "wild-addr-read"); - } else { - scariness.Scare(25, "wild-addr"); - } - } else { + if (signal.IsStackOverflow()) { + scariness.Scare(10, "stack-overflow"); + } else if (!signal.is_memory_access) { scariness.Scare(10, "signal"); + } else if (signal.addr < GetPageSizeCached()) { + scariness.Scare(10, "null-deref"); + } else if (signal.addr == signal.pc) { + scariness.Scare(60, "wild-jump"); + } else if (signal.write_flag == SignalContext::WRITE) { + scariness.Scare(30, "wild-addr-write"); + } else if (signal.write_flag == SignalContext::READ) { + scariness.Scare(20, "wild-addr-read"); + } else { + scariness.Scare(25, "wild-addr"); } } void Print(); @@ -304,7 +291,6 @@ // clang-format off #define ASAN_FOR_EACH_ERROR_KIND(macro) \ - macro(StackOverflow) \ macro(DeadlySignal) \ macro(DoubleFree) \ macro(NewDeleteSizeMismatch) \ Index: compiler-rt/lib/asan/asan_errors.cc =================================================================== --- compiler-rt/lib/asan/asan_errors.cc +++ compiler-rt/lib/asan/asan_errors.cc @@ -22,56 +22,56 @@ namespace __asan { -void ErrorStackOverflow::Print() { - Decorator d; - Printf("%s", d.Warning()); - Report( - "ERROR: AddressSanitizer: %s on address %p" - " (pc %p bp %p sp %p T%d)\n", - scariness.GetDescription(), (void *)signal.addr, (void *)signal.pc, - (void *)signal.bp, (void *)signal.sp, tid); - Printf("%s", d.Default()); - scariness.Print(); - BufferedStackTrace stack; - GetStackTraceWithPcBpAndContext(&stack, kStackTraceMax, signal.pc, signal.bp, - signal.context, - common_flags()->fast_unwind_on_fatal); - stack.Print(); - ReportErrorSummary(scariness.GetDescription(), &stack); -} - void ErrorDeadlySignal::Print() { - Decorator d; - Printf("%s", d.Warning()); - const char *description = signal.Describe(); - Report( - "ERROR: AddressSanitizer: %s on unknown address %p (pc %p bp %p sp %p " - "T%d)\n", - description, (void *)signal.addr, (void *)signal.pc, (void *)signal.bp, - (void *)signal.sp, tid); - Printf("%s", d.Default()); - if (signal.pc < GetPageSizeCached()) - Report("Hint: pc points to the zero page.\n"); - if (signal.is_memory_access) { - const char *access_type = - signal.write_flag == SignalContext::WRITE - ? "WRITE" - : (signal.write_flag == SignalContext::READ ? "READ" : "UNKNOWN"); - Report("The signal is caused by a %s memory access.\n", access_type); - if (signal.addr < GetPageSizeCached()) - Report("Hint: address points to the zero page.\n"); + if (signal.IsStackOverflow()) { + Decorator d; + Printf("%s", d.Warning()); + Report( + "ERROR: AddressSanitizer: %s on address %p" + " (pc %p bp %p sp %p T%d)\n", + scariness.GetDescription(), (void *)signal.addr, (void *)signal.pc, + (void *)signal.bp, (void *)signal.sp, tid); + Printf("%s", d.Default()); + scariness.Print(); + BufferedStackTrace stack; + GetStackTraceWithPcBpAndContext(&stack, kStackTraceMax, signal.pc, + signal.bp, signal.context, + common_flags()->fast_unwind_on_fatal); + stack.Print(); + ReportErrorSummary(scariness.GetDescription(), &stack); + } else { + Decorator d; + Printf("%s", d.Warning()); + const char *description = signal.Describe(); + Report( + "ERROR: AddressSanitizer: %s on unknown address %p (pc %p bp %p sp %p " + "T%d)\n", + description, (void *)signal.addr, (void *)signal.pc, (void *)signal.bp, + (void *)signal.sp, tid); + Printf("%s", d.Default()); + if (signal.pc < GetPageSizeCached()) + Report("Hint: pc points to the zero page.\n"); + if (signal.is_memory_access) { + const char *access_type = + signal.write_flag == SignalContext::WRITE + ? "WRITE" + : (signal.write_flag == SignalContext::READ ? "READ" : "UNKNOWN"); + Report("The signal is caused by a %s memory access.\n", access_type); + if (signal.addr < GetPageSizeCached()) + Report("Hint: address points to the zero page.\n"); + } + MaybeReportNonExecRegion(signal.pc); + scariness.Print(); + BufferedStackTrace stack; + GetStackTraceWithPcBpAndContext(&stack, kStackTraceMax, signal.pc, + signal.bp, signal.context, + common_flags()->fast_unwind_on_fatal); + stack.Print(); + MaybeDumpInstructionBytes(signal.pc); + MaybeDumpRegisters(signal.context); + Printf("AddressSanitizer can not provide additional info.\n"); + ReportErrorSummary(description, &stack); } - MaybeReportNonExecRegion(signal.pc); - scariness.Print(); - BufferedStackTrace stack; - GetStackTraceWithPcBpAndContext(&stack, kStackTraceMax, signal.pc, signal.bp, - signal.context, - common_flags()->fast_unwind_on_fatal); - stack.Print(); - MaybeDumpInstructionBytes(signal.pc); - MaybeDumpRegisters(signal.context); - Printf("AddressSanitizer can not provide additional info.\n"); - ReportErrorSummary(description, &stack); } void ErrorDoubleFree::Print() { Index: compiler-rt/lib/asan/asan_posix.cc =================================================================== --- compiler-rt/lib/asan/asan_posix.cc +++ compiler-rt/lib/asan/asan_posix.cc @@ -37,10 +37,7 @@ ScopedDeadlySignal signal_scope(GetCurrentThread()); StartReportDeadlySignal(); SignalContext sig(siginfo, context); - if (sig.IsStackOverflow()) - ReportStackOverflow(sig); - else - ReportDeadlySignal(sig); + ReportDeadlySignal(sig); } // ---------------------- TSD ---------------- {{{1 Index: compiler-rt/lib/asan/asan_report.h =================================================================== --- compiler-rt/lib/asan/asan_report.h +++ compiler-rt/lib/asan/asan_report.h @@ -46,7 +46,6 @@ // Different kinds of error reports. void ReportGenericError(uptr pc, uptr bp, uptr sp, uptr addr, bool is_write, uptr access_size, u32 exp, bool fatal); -void ReportStackOverflow(const SignalContext &sig); void ReportDeadlySignal(const SignalContext &sig); void ReportNewDeleteSizeMismatch(uptr addr, uptr delete_size, BufferedStackTrace *free_stack); Index: compiler-rt/lib/asan/asan_report.cc =================================================================== --- compiler-rt/lib/asan/asan_report.cc +++ compiler-rt/lib/asan/asan_report.cc @@ -260,12 +260,6 @@ u32 ScopedInErrorReport::reporting_thread_tid_ = kInvalidTid; ErrorDescription ScopedInErrorReport::current_error_; -void ReportStackOverflow(const SignalContext &sig) { - ScopedInErrorReport in_report(/*fatal*/ true); - ErrorStackOverflow error(GetCurrentTidOrInvalid(), sig); - in_report.ReportError(error); -} - void ReportDeadlySignal(const SignalContext &sig) { ScopedInErrorReport in_report(/*fatal*/ true); ErrorDeadlySignal error(GetCurrentTidOrInvalid(), sig);