Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Unified Diff: runtime/szrt_asan.c

Issue 2256673004: Subzero: Added address of bad instruction to error output (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Clarified error message Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests_lit/asan_tests/doublefree.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/szrt_asan.c
diff --git a/runtime/szrt_asan.c b/runtime/szrt_asan.c
index 302ed9a0b9735a78dfc9ee024f84b33038efc4bc..94fc47a4d76df393361623ac59d94f155dc37269 100644
--- a/runtime/szrt_asan.c
+++ b/runtime/szrt_asan.c
@@ -90,7 +90,7 @@ static const char *access_names[] = {"load from", "store to"};
static char *shadow_offset = NULL;
static bool __asan_check(char *, int);
-static void __asan_error(char *, int, int);
+static void __asan_error(char *, int, int, void *);
static void __asan_get_redzones(char *, char **, char **);
void __asan_init(int, void **, int *);
@@ -113,7 +113,7 @@ uint64_t quarantine_size = 0;
struct quarantine_entry *quarantine_head = NULL;
struct quarantine_entry *quarantine_tail = NULL;
-static void __asan_error(char *ptr, int size, int access) {
+static void __asan_error(char *ptr, int size, int access, void *ret_addr) {
char *shadow_addr = MEM2SHADOW(ptr);
char shadow_val = *shadow_addr;
if (shadow_val > 0)
@@ -123,8 +123,9 @@ static void __asan_error(char *ptr, int size, int access) {
assert(shadow_val == STACK_POISON_VAL || shadow_val == HEAP_POISON_VAL ||
shadow_val == GLOBAL_POISON_VAL || shadow_val == FREED_POISON_VAL);
const char *memtype = memtype_names[MEMTYPE_INDEX(shadow_val)];
- fprintf(stderr, "Illegal %d byte %s %s object at %p\n", size, access_name,
- memtype, ptr);
+ fprintf(stderr, "%p: Illegal %d byte %s %s object at %p\n", ret_addr, size,
+ access_name, memtype, ptr);
+ fprintf(stderr, "(address of __asan_error symbol is %p)\n", __asan_error);
abort();
}
@@ -156,13 +157,13 @@ void __asan_check_load(char *ptr, int size) {
int check_size =
(size == WORD_SIZE && (uintptr_t)ptr % WORD_SIZE == 0) ? 1 : size;
if (!__asan_check(ptr, check_size))
- __asan_error(ptr, size, ACCESS_LOAD);
+ __asan_error(ptr, size, ACCESS_LOAD, __builtin_return_address(0));
}
void __asan_check_store(char *ptr, int size) {
// stores may never be partially out of bounds so use strict check
if (!__asan_check(ptr, size))
- __asan_error(ptr, size, ACCESS_STORE);
+ __asan_error(ptr, size, ACCESS_STORE, __builtin_return_address(0));
}
void __asan_init(int n_rzs, void **rzs, int *rz_sizes) {
@@ -250,7 +251,9 @@ void __asan_free(char *ptr) {
if (ptr == NULL)
return;
if (*(char *)MEM2SHADOW(ptr) == FREED_POISON_VAL) {
- fprintf(stderr, "Double free of object at %p\n", ptr);
+ fprintf(stderr, "%p: Double free of object at %p\n",
+ __builtin_return_address(0), ptr);
+ fprintf(stderr, "(address of __asan_error symbol is %p)\n", __asan_error);
abort();
}
char *rz_left, *rz_right;
« no previous file with comments | « no previous file | tests_lit/asan_tests/doublefree.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698