Filipe Cabecinhas | fddfdca | 2016-08-30 17:08:55 +0000 | [diff] [blame] | 1 | //===-- asan_errors.cc ------------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file is a part of AddressSanitizer, an address sanity checker. |
| 11 | // |
| 12 | // ASan implementation for error structures. |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "asan_errors.h" |
Filipe Cabecinhas | b16672d | 2016-08-31 07:38:09 +0000 | [diff] [blame^] | 16 | #include "asan_descriptions.h" |
Filipe Cabecinhas | fddfdca | 2016-08-30 17:08:55 +0000 | [diff] [blame] | 17 | #include "asan_stack.h" |
| 18 | |
| 19 | namespace __asan { |
| 20 | |
| 21 | void ErrorStackOverflow::Print() { |
| 22 | Decorator d; |
| 23 | Printf("%s", d.Warning()); |
| 24 | Report( |
| 25 | "ERROR: AddressSanitizer: stack-overflow on address %p" |
| 26 | " (pc %p bp %p sp %p T%d)\n", |
| 27 | (void *)addr, (void *)pc, (void *)bp, (void *)sp, tid); |
| 28 | Printf("%s", d.EndWarning()); |
| 29 | scariness.Print(); |
| 30 | BufferedStackTrace stack; |
| 31 | GetStackTraceWithPcBpAndContext(&stack, kStackTraceMax, pc, bp, context, |
| 32 | common_flags()->fast_unwind_on_fatal); |
| 33 | stack.Print(); |
| 34 | ReportErrorSummary("stack-overflow", &stack); |
| 35 | } |
| 36 | |
Filipe Cabecinhas | b16672d | 2016-08-31 07:38:09 +0000 | [diff] [blame^] | 37 | void ErrorDoubleFree::Print() { |
| 38 | Decorator d; |
| 39 | Printf("%s", d.Warning()); |
| 40 | char tname[128]; |
| 41 | Report( |
| 42 | "ERROR: AddressSanitizer: attempting double-free on %p in " |
| 43 | "thread T%d%s:\n", |
| 44 | addr_description.addr, tid, |
| 45 | ThreadNameWithParenthesis(tid, tname, sizeof(tname))); |
| 46 | Printf("%s", d.EndWarning()); |
| 47 | GET_STACK_TRACE_FATAL(second_free_stack->trace[0], |
| 48 | second_free_stack->top_frame_bp); |
| 49 | stack.Print(); |
| 50 | addr_description.Print(); |
| 51 | ReportErrorSummary("double-free", &stack); |
| 52 | } |
| 53 | |
Filipe Cabecinhas | fddfdca | 2016-08-30 17:08:55 +0000 | [diff] [blame] | 54 | } // namespace __asan |