blob: b1ab07ee894ea7f603307a42a9ecc305d53f7b46 [file] [log] [blame]
Filipe Cabecinhasfddfdca2016-08-30 17:08:55 +00001//===-- 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 Cabecinhasb16672d2016-08-31 07:38:09 +000016#include "asan_descriptions.h"
Filipe Cabecinhasfddfdca2016-08-30 17:08:55 +000017#include "asan_stack.h"
18
19namespace __asan {
20
21void 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 Cabecinhasb16672d2016-08-31 07:38:09 +000037void 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 Cabecinhasfddfdca2016-08-30 17:08:55 +000054} // namespace __asan