[asan] poison the internal asan heap memory, just in case. Change Printf to Report when debugging globals.

llvm-svn: 146663
This commit is contained in:
Kostya Serebryany 2011-12-15 17:41:30 +00:00
parent 843e978324
commit 7fb33a3d40
3 changed files with 4 additions and 1 deletions

View File

@ -117,7 +117,7 @@ static void RegisterGlobal(const Global *g) {
l->next = list_of_globals;
list_of_globals = l;
if (FLAG_report_globals >= 2)
Printf("Added Global: beg=%p size=%ld name=%s\n",
Report("Added Global: beg=%p size=%ld name=%s\n",
g->beg, g->size, g->name);
}

View File

@ -180,6 +180,7 @@ const int kAsanStackPartialRedzoneMagic = 0xf4;
const int kAsanStackAfterReturnMagic = 0xf5;
const int kAsanUserPoisonedMemoryMagic = 0xf7;
const int kAsanGlobalRedzoneMagic = 0xf9;
const int kAsanInternalHeapMagic = 0xfe;
static const uintptr_t kCurrentStackFrameMagic = 0x41B58AB3;
static const uintptr_t kRetiredStackFrameMagic = 0x45E0360E;

View File

@ -178,6 +178,8 @@ void *LowLevelAllocator::Allocate(size_t size) {
MAP_PRIVATE | MAP_ANON, -1, 0);
CHECK((allocated_current_ != (char*)-1) && "Can't mmap");
allocated_end_ = allocated_current_ + size_to_allocate;
PoisonShadow((uintptr_t)allocated_current_, size_to_allocate,
kAsanInternalHeapMagic);
}
CHECK(allocated_end_ - allocated_current_ >= size);
void *res = allocated_current_;