forked from OSchip/llvm-project
[asan] Remove ErrorStackOverflow
Summary: The only difference from ErrorDeadlySignal is reporting code and it lives in sanitizer common. Part of https://github.com/google/sanitizers/issues/637 Reviewers: eugenis, alekseyshl, filcab Subscribers: llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D37868 llvm-svn: 313309
This commit is contained in:
parent
c4600ccf89
commit
846a217bfc
|
@ -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() {
|
||||
|
|
|
@ -27,19 +27,6 @@ struct ErrorBase {
|
|||
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 @@ struct ErrorDeadlySignal : ErrorBase {
|
|||
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 @@ struct ErrorGeneric : ErrorBase {
|
|||
|
||||
// clang-format off
|
||||
#define ASAN_FOR_EACH_ERROR_KIND(macro) \
|
||||
macro(StackOverflow) \
|
||||
macro(DeadlySignal) \
|
||||
macro(DoubleFree) \
|
||||
macro(NewDeleteSizeMismatch) \
|
||||
|
|
|
@ -37,10 +37,7 @@ void AsanOnDeadlySignal(int signo, void *siginfo, void *context) {
|
|||
ScopedDeadlySignal signal_scope(GetCurrentThread());
|
||||
StartReportDeadlySignal();
|
||||
SignalContext sig(siginfo, context);
|
||||
if (sig.IsStackOverflow())
|
||||
ReportStackOverflow(sig);
|
||||
else
|
||||
ReportDeadlySignal(sig);
|
||||
ReportDeadlySignal(sig);
|
||||
}
|
||||
|
||||
// ---------------------- TSD ---------------- {{{1
|
||||
|
|
|
@ -260,12 +260,6 @@ StaticSpinMutex ScopedInErrorReport::lock_;
|
|||
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);
|
||||
|
|
|
@ -46,7 +46,6 @@ bool ParseFrameDescription(const char *frame_descr,
|
|||
// 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);
|
||||
|
|
Loading…
Reference in New Issue