blob: d42a86850cde472480664c54f539ab868b8f600b [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 Cabecinhas1989be72016-09-08 12:58:15 +000016#include <signal.h>
Filipe Cabecinhasb16672d2016-08-31 07:38:09 +000017#include "asan_descriptions.h"
Filipe Cabecinhasb50a5b32016-09-15 08:10:48 +000018#include "asan_mapping.h"
Filipe Cabecinhas1989be72016-09-08 12:58:15 +000019#include "asan_report.h"
Filipe Cabecinhasfddfdca2016-08-30 17:08:55 +000020#include "asan_stack.h"
Filipe Cabecinhas719db0c2016-09-15 08:10:52 +000021#include "sanitizer_common/sanitizer_stackdepot.h"
Filipe Cabecinhasfddfdca2016-08-30 17:08:55 +000022
23namespace __asan {
24
Vitaly Buka21ddc622017-09-14 22:44:03 +000025static void OnStackUnwind(const SignalContext &sig,
26 const void *callback_context,
27 BufferedStackTrace *stack) {
Vitaly Buka86dd0882017-09-18 06:56:57 +000028 bool fast = common_flags()->fast_unwind_on_fatal;
29#if SANITIZER_FREEBSD || SANITIZER_NETBSD
30 // On FreeBSD the slow unwinding that leverages _Unwind_Backtrace()
31 // yields the call stack of the signal's handler and not of the code
32 // that raised the signal (as it does on Linux).
33 fast = true;
34#endif
Vitaly Buka21ddc622017-09-14 22:44:03 +000035 // Tests and maybe some users expect that scariness is going to be printed
36 // just before the stack. As only asan has scariness score we have no
37 // corresponding code in the sanitizer_common and we use this callback to
38 // print it.
39 static_cast<const ScarinessScoreBase *>(callback_context)->Print();
40 GetStackTraceWithPcBpAndContext(stack, kStackTraceMax, sig.pc, sig.bp,
Vitaly Buka86dd0882017-09-18 06:56:57 +000041 sig.context, fast);
Vitaly Buka21ddc622017-09-14 22:44:03 +000042}
43
Filipe Cabecinhas1989be72016-09-08 12:58:15 +000044void ErrorDeadlySignal::Print() {
Vitaly Buka21ddc622017-09-14 22:44:03 +000045 ReportDeadlySignal(signal, tid, &OnStackUnwind, &scariness);
Filipe Cabecinhas1989be72016-09-08 12:58:15 +000046}
47
Filipe Cabecinhasb16672d2016-08-31 07:38:09 +000048void ErrorDoubleFree::Print() {
49 Decorator d;
50 Printf("%s", d.Warning());
51 char tname[128];
52 Report(
Kuba Mracek48090f52016-11-28 21:18:15 +000053 "ERROR: AddressSanitizer: attempting %s on %p in "
Filipe Cabecinhasb16672d2016-08-31 07:38:09 +000054 "thread T%d%s:\n",
Kuba Mracek48090f52016-11-28 21:18:15 +000055 scariness.GetDescription(), addr_description.addr, tid,
Filipe Cabecinhasb16672d2016-08-31 07:38:09 +000056 ThreadNameWithParenthesis(tid, tname, sizeof(tname)));
Vitaly Buka36266b62017-09-11 20:55:49 +000057 Printf("%s", d.Default());
Filipe Cabecinhas453b5552016-08-31 09:39:47 +000058 scariness.Print();
Filipe Cabecinhasb16672d2016-08-31 07:38:09 +000059 GET_STACK_TRACE_FATAL(second_free_stack->trace[0],
60 second_free_stack->top_frame_bp);
61 stack.Print();
62 addr_description.Print();
Kuba Mracek48090f52016-11-28 21:18:15 +000063 ReportErrorSummary(scariness.GetDescription(), &stack);
Filipe Cabecinhasb16672d2016-08-31 07:38:09 +000064}
65
Filipe Cabecinhas25ad7b52016-09-07 14:20:54 +000066void ErrorNewDeleteSizeMismatch::Print() {
67 Decorator d;
68 Printf("%s", d.Warning());
69 char tname[128];
70 Report(
Kuba Mracek48090f52016-11-28 21:18:15 +000071 "ERROR: AddressSanitizer: %s on %p in thread "
Filipe Cabecinhas25ad7b52016-09-07 14:20:54 +000072 "T%d%s:\n",
Kuba Mracek48090f52016-11-28 21:18:15 +000073 scariness.GetDescription(), addr_description.addr, tid,
Filipe Cabecinhas25ad7b52016-09-07 14:20:54 +000074 ThreadNameWithParenthesis(tid, tname, sizeof(tname)));
Vitaly Buka36266b62017-09-11 20:55:49 +000075 Printf("%s object passed to delete has wrong type:\n", d.Default());
Filipe Cabecinhas25ad7b52016-09-07 14:20:54 +000076 Printf(
77 " size of the allocated type: %zd bytes;\n"
78 " size of the deallocated type: %zd bytes.\n",
79 addr_description.chunk_access.chunk_size, delete_size);
80 CHECK_GT(free_stack->size, 0);
81 scariness.Print();
82 GET_STACK_TRACE_FATAL(free_stack->trace[0], free_stack->top_frame_bp);
83 stack.Print();
84 addr_description.Print();
Kuba Mracek48090f52016-11-28 21:18:15 +000085 ReportErrorSummary(scariness.GetDescription(), &stack);
Filipe Cabecinhas25ad7b52016-09-07 14:20:54 +000086 Report(
87 "HINT: if you don't care about these errors you may set "
88 "ASAN_OPTIONS=new_delete_type_mismatch=0\n");
89}
90
Filipe Cabecinhas6fb54622016-09-13 20:47:29 +000091void ErrorFreeNotMalloced::Print() {
92 Decorator d;
93 Printf("%s", d.Warning());
94 char tname[128];
95 Report(
96 "ERROR: AddressSanitizer: attempting free on address "
97 "which was not malloc()-ed: %p in thread T%d%s\n",
98 addr_description.Address(), tid,
99 ThreadNameWithParenthesis(tid, tname, sizeof(tname)));
Vitaly Buka36266b62017-09-11 20:55:49 +0000100 Printf("%s", d.Default());
Filipe Cabecinhas6fb54622016-09-13 20:47:29 +0000101 CHECK_GT(free_stack->size, 0);
102 scariness.Print();
103 GET_STACK_TRACE_FATAL(free_stack->trace[0], free_stack->top_frame_bp);
104 stack.Print();
105 addr_description.Print();
Kuba Mracek48090f52016-11-28 21:18:15 +0000106 ReportErrorSummary(scariness.GetDescription(), &stack);
Filipe Cabecinhas6fb54622016-09-13 20:47:29 +0000107}
108
Filipe Cabecinhas92c5b5d2016-09-13 20:47:33 +0000109void ErrorAllocTypeMismatch::Print() {
110 static const char *alloc_names[] = {"INVALID", "malloc", "operator new",
111 "operator new []"};
112 static const char *dealloc_names[] = {"INVALID", "free", "operator delete",
113 "operator delete []"};
114 CHECK_NE(alloc_type, dealloc_type);
115 Decorator d;
116 Printf("%s", d.Warning());
Kuba Mracek48090f52016-11-28 21:18:15 +0000117 Report("ERROR: AddressSanitizer: %s (%s vs %s) on %p\n",
118 scariness.GetDescription(),
Filipe Cabecinhas92c5b5d2016-09-13 20:47:33 +0000119 alloc_names[alloc_type], dealloc_names[dealloc_type],
120 addr_description.addr);
Vitaly Buka36266b62017-09-11 20:55:49 +0000121 Printf("%s", d.Default());
Filipe Cabecinhas92c5b5d2016-09-13 20:47:33 +0000122 CHECK_GT(dealloc_stack->size, 0);
123 scariness.Print();
124 GET_STACK_TRACE_FATAL(dealloc_stack->trace[0], dealloc_stack->top_frame_bp);
125 stack.Print();
126 addr_description.Print();
Kuba Mracek48090f52016-11-28 21:18:15 +0000127 ReportErrorSummary(scariness.GetDescription(), &stack);
Filipe Cabecinhas92c5b5d2016-09-13 20:47:33 +0000128 Report(
129 "HINT: if you don't care about these errors you may set "
130 "ASAN_OPTIONS=alloc_dealloc_mismatch=0\n");
131}
132
Filipe Cabecinhas5f862c22016-09-13 20:47:37 +0000133void ErrorMallocUsableSizeNotOwned::Print() {
134 Decorator d;
135 Printf("%s", d.Warning());
136 Report(
137 "ERROR: AddressSanitizer: attempting to call malloc_usable_size() for "
138 "pointer which is not owned: %p\n",
139 addr_description.Address());
Vitaly Buka36266b62017-09-11 20:55:49 +0000140 Printf("%s", d.Default());
Filipe Cabecinhas5f862c22016-09-13 20:47:37 +0000141 stack->Print();
142 addr_description.Print();
Kuba Mracek48090f52016-11-28 21:18:15 +0000143 ReportErrorSummary(scariness.GetDescription(), stack);
Filipe Cabecinhas5f862c22016-09-13 20:47:37 +0000144}
145
Filipe Cabecinhasb0de43a2016-09-13 20:47:42 +0000146void ErrorSanitizerGetAllocatedSizeNotOwned::Print() {
147 Decorator d;
148 Printf("%s", d.Warning());
149 Report(
150 "ERROR: AddressSanitizer: attempting to call "
151 "__sanitizer_get_allocated_size() for pointer which is not owned: %p\n",
152 addr_description.Address());
Vitaly Buka36266b62017-09-11 20:55:49 +0000153 Printf("%s", d.Default());
Filipe Cabecinhasb0de43a2016-09-13 20:47:42 +0000154 stack->Print();
155 addr_description.Print();
Kuba Mracek48090f52016-11-28 21:18:15 +0000156 ReportErrorSummary(scariness.GetDescription(), stack);
Filipe Cabecinhasb0de43a2016-09-13 20:47:42 +0000157}
158
Filipe Cabecinhas7a196b92016-09-14 07:37:14 +0000159void ErrorStringFunctionMemoryRangesOverlap::Print() {
160 Decorator d;
161 char bug_type[100];
162 internal_snprintf(bug_type, sizeof(bug_type), "%s-param-overlap", function);
163 Printf("%s", d.Warning());
164 Report(
165 "ERROR: AddressSanitizer: %s: memory ranges [%p,%p) and [%p, %p) "
166 "overlap\n",
167 bug_type, addr1_description.Address(),
168 addr1_description.Address() + length1, addr2_description.Address(),
169 addr2_description.Address() + length2);
Vitaly Buka36266b62017-09-11 20:55:49 +0000170 Printf("%s", d.Default());
Filipe Cabecinhas7a196b92016-09-14 07:37:14 +0000171 scariness.Print();
172 stack->Print();
173 addr1_description.Print();
174 addr2_description.Print();
175 ReportErrorSummary(bug_type, stack);
176}
177
Filipe Cabecinhas36229e92016-09-14 07:37:20 +0000178void ErrorStringFunctionSizeOverflow::Print() {
179 Decorator d;
180 Printf("%s", d.Warning());
Kuba Mracek48090f52016-11-28 21:18:15 +0000181 Report("ERROR: AddressSanitizer: %s: (size=%zd)\n",
182 scariness.GetDescription(), size);
Vitaly Buka36266b62017-09-11 20:55:49 +0000183 Printf("%s", d.Default());
Filipe Cabecinhas36229e92016-09-14 07:37:20 +0000184 scariness.Print();
185 stack->Print();
186 addr_description.Print();
Kuba Mracek48090f52016-11-28 21:18:15 +0000187 ReportErrorSummary(scariness.GetDescription(), stack);
Filipe Cabecinhas36229e92016-09-14 07:37:20 +0000188}
189
Filipe Cabecinhasb50a5b32016-09-15 08:10:48 +0000190void ErrorBadParamsToAnnotateContiguousContainer::Print() {
191 Report(
192 "ERROR: AddressSanitizer: bad parameters to "
193 "__sanitizer_annotate_contiguous_container:\n"
194 " beg : %p\n"
195 " end : %p\n"
196 " old_mid : %p\n"
197 " new_mid : %p\n",
198 beg, end, old_mid, new_mid);
199 uptr granularity = SHADOW_GRANULARITY;
200 if (!IsAligned(beg, granularity))
201 Report("ERROR: beg is not aligned by %d\n", granularity);
202 stack->Print();
Kuba Mracek48090f52016-11-28 21:18:15 +0000203 ReportErrorSummary(scariness.GetDescription(), stack);
Filipe Cabecinhasb50a5b32016-09-15 08:10:48 +0000204}
205
Filipe Cabecinhas719db0c2016-09-15 08:10:52 +0000206void ErrorODRViolation::Print() {
207 Decorator d;
208 Printf("%s", d.Warning());
Kuba Mracek48090f52016-11-28 21:18:15 +0000209 Report("ERROR: AddressSanitizer: %s (%p):\n", scariness.GetDescription(),
210 global1.beg);
Vitaly Buka36266b62017-09-11 20:55:49 +0000211 Printf("%s", d.Default());
Filipe Cabecinhas719db0c2016-09-15 08:10:52 +0000212 InternalScopedString g1_loc(256), g2_loc(256);
213 PrintGlobalLocation(&g1_loc, global1);
214 PrintGlobalLocation(&g2_loc, global2);
215 Printf(" [1] size=%zd '%s' %s\n", global1.size,
216 MaybeDemangleGlobalName(global1.name), g1_loc.data());
217 Printf(" [2] size=%zd '%s' %s\n", global2.size,
218 MaybeDemangleGlobalName(global2.name), g2_loc.data());
219 if (stack_id1 && stack_id2) {
220 Printf("These globals were registered at these points:\n");
221 Printf(" [1]:\n");
222 StackDepotGet(stack_id1).Print();
223 Printf(" [2]:\n");
224 StackDepotGet(stack_id2).Print();
225 }
226 Report(
227 "HINT: if you don't care about these errors you may set "
228 "ASAN_OPTIONS=detect_odr_violation=0\n");
229 InternalScopedString error_msg(256);
Kuba Mracek48090f52016-11-28 21:18:15 +0000230 error_msg.append("%s: global '%s' at %s", scariness.GetDescription(),
Filipe Cabecinhas719db0c2016-09-15 08:10:52 +0000231 MaybeDemangleGlobalName(global1.name), g1_loc.data());
232 ReportErrorSummary(error_msg.data());
233}
234
Filipe Cabecinhas1b3742e2016-09-15 08:10:56 +0000235void ErrorInvalidPointerPair::Print() {
Filipe Cabecinhas1b3742e2016-09-15 08:10:56 +0000236 Decorator d;
237 Printf("%s", d.Warning());
Kuba Mracek48090f52016-11-28 21:18:15 +0000238 Report("ERROR: AddressSanitizer: %s: %p %p\n", scariness.GetDescription(),
Filipe Cabecinhas490f96c2016-09-21 19:21:01 +0000239 addr1_description.Address(), addr2_description.Address());
Vitaly Buka36266b62017-09-11 20:55:49 +0000240 Printf("%s", d.Default());
Filipe Cabecinhas1b3742e2016-09-15 08:10:56 +0000241 GET_STACK_TRACE_FATAL(pc, bp);
242 stack.Print();
Filipe Cabecinhas490f96c2016-09-21 19:21:01 +0000243 addr1_description.Print();
244 addr2_description.Print();
Kuba Mracek48090f52016-11-28 21:18:15 +0000245 ReportErrorSummary(scariness.GetDescription(), &stack);
Filipe Cabecinhas1b3742e2016-09-15 08:10:56 +0000246}
247
Filipe Cabecinhasa8b5f5e2016-09-21 20:18:18 +0000248static bool AdjacentShadowValuesAreFullyPoisoned(u8 *s) {
249 return s[-1] > 127 && s[1] > 127;
250}
251
252ErrorGeneric::ErrorGeneric(u32 tid, uptr pc_, uptr bp_, uptr sp_, uptr addr,
253 bool is_write_, uptr access_size_)
254 : ErrorBase(tid),
255 addr_description(addr, access_size_, /*shouldLockThreadRegistry=*/false),
256 pc(pc_),
257 bp(bp_),
258 sp(sp_),
259 access_size(access_size_),
260 is_write(is_write_),
261 shadow_val(0) {
262 scariness.Clear();
263 if (access_size) {
264 if (access_size <= 9) {
265 char desr[] = "?-byte";
266 desr[0] = '0' + access_size;
267 scariness.Scare(access_size + access_size / 2, desr);
268 } else if (access_size >= 10) {
269 scariness.Scare(15, "multi-byte");
270 }
271 is_write ? scariness.Scare(20, "write") : scariness.Scare(1, "read");
272
273 // Determine the error type.
274 bug_descr = "unknown-crash";
275 if (AddrIsInMem(addr)) {
276 u8 *shadow_addr = (u8 *)MemToShadow(addr);
277 // If we are accessing 16 bytes, look at the second shadow byte.
278 if (*shadow_addr == 0 && access_size > SHADOW_GRANULARITY) shadow_addr++;
279 // If we are in the partial right redzone, look at the next shadow byte.
280 if (*shadow_addr > 0 && *shadow_addr < 128) shadow_addr++;
281 bool far_from_bounds = false;
282 shadow_val = *shadow_addr;
283 int bug_type_score = 0;
284 // For use-after-frees reads are almost as bad as writes.
285 int read_after_free_bonus = 0;
286 switch (shadow_val) {
287 case kAsanHeapLeftRedzoneMagic:
288 case kAsanArrayCookieMagic:
289 bug_descr = "heap-buffer-overflow";
290 bug_type_score = 10;
291 far_from_bounds = AdjacentShadowValuesAreFullyPoisoned(shadow_addr);
292 break;
293 case kAsanHeapFreeMagic:
294 bug_descr = "heap-use-after-free";
295 bug_type_score = 20;
296 if (!is_write) read_after_free_bonus = 18;
297 break;
298 case kAsanStackLeftRedzoneMagic:
299 bug_descr = "stack-buffer-underflow";
300 bug_type_score = 25;
301 far_from_bounds = AdjacentShadowValuesAreFullyPoisoned(shadow_addr);
302 break;
303 case kAsanInitializationOrderMagic:
304 bug_descr = "initialization-order-fiasco";
305 bug_type_score = 1;
306 break;
307 case kAsanStackMidRedzoneMagic:
308 case kAsanStackRightRedzoneMagic:
309 bug_descr = "stack-buffer-overflow";
310 bug_type_score = 25;
311 far_from_bounds = AdjacentShadowValuesAreFullyPoisoned(shadow_addr);
312 break;
313 case kAsanStackAfterReturnMagic:
314 bug_descr = "stack-use-after-return";
315 bug_type_score = 30;
316 if (!is_write) read_after_free_bonus = 18;
317 break;
318 case kAsanUserPoisonedMemoryMagic:
319 bug_descr = "use-after-poison";
320 bug_type_score = 20;
321 break;
322 case kAsanContiguousContainerOOBMagic:
323 bug_descr = "container-overflow";
324 bug_type_score = 10;
325 break;
326 case kAsanStackUseAfterScopeMagic:
327 bug_descr = "stack-use-after-scope";
328 bug_type_score = 10;
329 break;
330 case kAsanGlobalRedzoneMagic:
331 bug_descr = "global-buffer-overflow";
332 bug_type_score = 10;
333 far_from_bounds = AdjacentShadowValuesAreFullyPoisoned(shadow_addr);
334 break;
335 case kAsanIntraObjectRedzone:
336 bug_descr = "intra-object-overflow";
337 bug_type_score = 10;
338 break;
339 case kAsanAllocaLeftMagic:
340 case kAsanAllocaRightMagic:
341 bug_descr = "dynamic-stack-buffer-overflow";
342 bug_type_score = 25;
343 far_from_bounds = AdjacentShadowValuesAreFullyPoisoned(shadow_addr);
344 break;
345 }
346 scariness.Scare(bug_type_score + read_after_free_bonus, bug_descr);
347 if (far_from_bounds) scariness.Scare(10, "far-from-bounds");
348 }
349 }
350}
351
352static void PrintContainerOverflowHint() {
353 Printf("HINT: if you don't care about these errors you may set "
354 "ASAN_OPTIONS=detect_container_overflow=0.\n"
355 "If you suspect a false positive see also: "
356 "https://github.com/google/sanitizers/wiki/"
357 "AddressSanitizerContainerOverflow.\n");
358}
359
360static void PrintShadowByte(InternalScopedString *str, const char *before,
361 u8 byte, const char *after = "\n") {
362 PrintMemoryByte(str, before, byte, /*in_shadow*/true, after);
363}
364
365static void PrintLegend(InternalScopedString *str) {
366 str->append(
367 "Shadow byte legend (one shadow byte represents %d "
368 "application bytes):\n",
369 (int)SHADOW_GRANULARITY);
370 PrintShadowByte(str, " Addressable: ", 0);
371 str->append(" Partially addressable: ");
372 for (u8 i = 1; i < SHADOW_GRANULARITY; i++) PrintShadowByte(str, "", i, " ");
373 str->append("\n");
374 PrintShadowByte(str, " Heap left redzone: ",
375 kAsanHeapLeftRedzoneMagic);
376 PrintShadowByte(str, " Freed heap region: ", kAsanHeapFreeMagic);
377 PrintShadowByte(str, " Stack left redzone: ",
378 kAsanStackLeftRedzoneMagic);
379 PrintShadowByte(str, " Stack mid redzone: ",
380 kAsanStackMidRedzoneMagic);
381 PrintShadowByte(str, " Stack right redzone: ",
382 kAsanStackRightRedzoneMagic);
383 PrintShadowByte(str, " Stack after return: ",
384 kAsanStackAfterReturnMagic);
385 PrintShadowByte(str, " Stack use after scope: ",
386 kAsanStackUseAfterScopeMagic);
387 PrintShadowByte(str, " Global redzone: ", kAsanGlobalRedzoneMagic);
388 PrintShadowByte(str, " Global init order: ",
389 kAsanInitializationOrderMagic);
390 PrintShadowByte(str, " Poisoned by user: ",
391 kAsanUserPoisonedMemoryMagic);
392 PrintShadowByte(str, " Container overflow: ",
393 kAsanContiguousContainerOOBMagic);
394 PrintShadowByte(str, " Array cookie: ",
395 kAsanArrayCookieMagic);
396 PrintShadowByte(str, " Intra object redzone: ",
397 kAsanIntraObjectRedzone);
398 PrintShadowByte(str, " ASan internal: ", kAsanInternalHeapMagic);
399 PrintShadowByte(str, " Left alloca redzone: ", kAsanAllocaLeftMagic);
400 PrintShadowByte(str, " Right alloca redzone: ", kAsanAllocaRightMagic);
401}
402
403static void PrintShadowBytes(InternalScopedString *str, const char *before,
404 u8 *bytes, u8 *guilty, uptr n) {
405 Decorator d;
406 if (before) str->append("%s%p:", before, bytes);
407 for (uptr i = 0; i < n; i++) {
408 u8 *p = bytes + i;
409 const char *before =
410 p == guilty ? "[" : (p - 1 == guilty && i != 0) ? "" : " ";
411 const char *after = p == guilty ? "]" : "";
412 PrintShadowByte(str, before, *p, after);
413 }
414 str->append("\n");
415}
416
417static void PrintShadowMemoryForAddress(uptr addr) {
418 if (!AddrIsInMem(addr)) return;
419 uptr shadow_addr = MemToShadow(addr);
420 const uptr n_bytes_per_row = 16;
421 uptr aligned_shadow = shadow_addr & ~(n_bytes_per_row - 1);
422 InternalScopedString str(4096 * 8);
423 str.append("Shadow bytes around the buggy address:\n");
424 for (int i = -5; i <= 5; i++) {
425 const char *prefix = (i == 0) ? "=>" : " ";
426 PrintShadowBytes(&str, prefix, (u8 *)(aligned_shadow + i * n_bytes_per_row),
427 (u8 *)shadow_addr, n_bytes_per_row);
428 }
429 if (flags()->print_legend) PrintLegend(&str);
430 Printf("%s", str.data());
431}
432
433void ErrorGeneric::Print() {
434 Decorator d;
435 Printf("%s", d.Warning());
436 uptr addr = addr_description.Address();
437 Report("ERROR: AddressSanitizer: %s on address %p at pc %p bp %p sp %p\n",
438 bug_descr, (void *)addr, pc, bp, sp);
Vitaly Buka36266b62017-09-11 20:55:49 +0000439 Printf("%s", d.Default());
Filipe Cabecinhasa8b5f5e2016-09-21 20:18:18 +0000440
441 char tname[128];
442 Printf("%s%s of size %zu at %p thread T%d%s%s\n", d.Access(),
443 access_size ? (is_write ? "WRITE" : "READ") : "ACCESS", access_size,
444 (void *)addr, tid,
Vitaly Buka36266b62017-09-11 20:55:49 +0000445 ThreadNameWithParenthesis(tid, tname, sizeof(tname)), d.Default());
Filipe Cabecinhasa8b5f5e2016-09-21 20:18:18 +0000446
447 scariness.Print();
448 GET_STACK_TRACE_FATAL(pc, bp);
449 stack.Print();
450
451 // Pass bug_descr because we have a special case for
452 // initialization-order-fiasco
453 addr_description.Print(bug_descr);
454 if (shadow_val == kAsanContiguousContainerOOBMagic)
455 PrintContainerOverflowHint();
456 ReportErrorSummary(bug_descr, &stack);
457 PrintShadowMemoryForAddress(addr);
458}
459
Filipe Cabecinhasfddfdca2016-08-30 17:08:55 +0000460} // namespace __asan