|
@@ -70,8 +70,8 @@ void MallocTracer::target_did_free(Badge<SoftCPU>, FlatPtr address)
|
|
|
for (auto& mallocation : m_mallocations) {
|
|
|
if (mallocation.address == address) {
|
|
|
if (mallocation.freed) {
|
|
|
- warnf("\n=={}== \033[31;1mDouble free()\033[0m, {:p}", getpid(), address);
|
|
|
- warnf("=={}== Address {} has already been passed to free()", getpid(), address);
|
|
|
+ warnln("\n=={}== \033[31;1mDouble free()\033[0m, {:p}", getpid(), address);
|
|
|
+ warnln("=={}== Address {} has already been passed to free()", getpid(), address);
|
|
|
Emulator::the().dump_backtrace();
|
|
|
} else {
|
|
|
mallocation.freed = true;
|
|
@@ -81,8 +81,8 @@ void MallocTracer::target_did_free(Badge<SoftCPU>, FlatPtr address)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- warnf("\n=={}== \033[31;1mInvalid free()\033[0m, {:p}", getpid(), address);
|
|
|
- warnf("=={}== Address {} has never been returned by malloc()", getpid(), address);
|
|
|
+ warnln("\n=={}== \033[31;1mInvalid free()\033[0m, {:p}", getpid(), address);
|
|
|
+ warnln("=={}== Address {} has never been returned by malloc()", getpid(), address);
|
|
|
Emulator::the().dump_backtrace();
|
|
|
}
|
|
|
|
|
@@ -118,11 +118,11 @@ void MallocTracer::audit_read(FlatPtr address, size_t size)
|
|
|
auto* mallocation = find_mallocation(address);
|
|
|
|
|
|
if (!mallocation) {
|
|
|
- warnf("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte read at address {:p}", getpid(), size, address);
|
|
|
+ warnln("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte read at address {:p}", getpid(), size, address);
|
|
|
Emulator::the().dump_backtrace();
|
|
|
if ((mallocation = find_mallocation_before(address))) {
|
|
|
size_t offset_into_mallocation = address - mallocation->address;
|
|
|
- warnf("=={}== Address is {} byte(s) after block of size {}, allocated at:", getpid(), offset_into_mallocation - mallocation->size, mallocation->size);
|
|
|
+ warnln("=={}== Address is {} byte(s) after block of size {}, allocated at:", getpid(), offset_into_mallocation - mallocation->size, mallocation->size);
|
|
|
Emulator::the().dump_backtrace(mallocation->malloc_backtrace);
|
|
|
}
|
|
|
return;
|
|
@@ -131,11 +131,11 @@ void MallocTracer::audit_read(FlatPtr address, size_t size)
|
|
|
size_t offset_into_mallocation = address - mallocation->address;
|
|
|
|
|
|
if (mallocation->freed) {
|
|
|
- warnf("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte read at address {:p}", getpid(), size, address);
|
|
|
+ warnln("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte read at address {:p}", getpid(), size, address);
|
|
|
Emulator::the().dump_backtrace();
|
|
|
- warnf("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size);
|
|
|
+ warnln("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size);
|
|
|
Emulator::the().dump_backtrace(mallocation->malloc_backtrace);
|
|
|
- warnf("=={}== Later freed at:", getpid());
|
|
|
+ warnln("=={}== Later freed at:", getpid());
|
|
|
Emulator::the().dump_backtrace(mallocation->free_backtrace);
|
|
|
return;
|
|
|
}
|
|
@@ -151,11 +151,11 @@ void MallocTracer::audit_write(FlatPtr address, size_t size)
|
|
|
|
|
|
auto* mallocation = find_mallocation(address);
|
|
|
if (!mallocation) {
|
|
|
- warnf("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte write at address {:p}", getpid(), size, address);
|
|
|
+ warnln("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte write at address {:p}", getpid(), size, address);
|
|
|
Emulator::the().dump_backtrace();
|
|
|
if ((mallocation = find_mallocation_before(address))) {
|
|
|
size_t offset_into_mallocation = address - mallocation->address;
|
|
|
- warnf("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size);
|
|
|
+ warnln("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size);
|
|
|
Emulator::the().dump_backtrace(mallocation->malloc_backtrace);
|
|
|
}
|
|
|
return;
|
|
@@ -164,11 +164,11 @@ void MallocTracer::audit_write(FlatPtr address, size_t size)
|
|
|
size_t offset_into_mallocation = address - mallocation->address;
|
|
|
|
|
|
if (mallocation->freed) {
|
|
|
- warnf("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte write at address {:p}", getpid(), size, address);
|
|
|
+ warnln("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte write at address {:p}", getpid(), size, address);
|
|
|
Emulator::the().dump_backtrace();
|
|
|
- warnf("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size);
|
|
|
+ warnln("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size);
|
|
|
Emulator::the().dump_backtrace(mallocation->malloc_backtrace);
|
|
|
- warnf("=={}== Later freed at:", getpid());
|
|
|
+ warnln("=={}== Later freed at:", getpid());
|
|
|
Emulator::the().dump_backtrace(mallocation->free_backtrace);
|
|
|
return;
|
|
|
}
|
|
@@ -189,7 +189,7 @@ bool MallocTracer::is_reachable(const Mallocation& mallocation) const
|
|
|
auto value = Emulator::the().mmu().read32({ 0x20, other_mallocation.address + i * sizeof(u32) });
|
|
|
if (value.value() == mallocation.address && !value.is_uninitialized()) {
|
|
|
#ifdef REACHABLE_DEBUG
|
|
|
- warnf("mallocation {:p} is reachable from other mallocation {:p}", mallocation.address, other_mallocation.address);
|
|
|
+ warnln("mallocation {:p} is reachable from other mallocation {:p}", mallocation.address, other_mallocation.address);
|
|
|
#endif
|
|
|
return true;
|
|
|
}
|
|
@@ -214,7 +214,7 @@ bool MallocTracer::is_reachable(const Mallocation& mallocation) const
|
|
|
auto value = region.read32(i * sizeof(u32));
|
|
|
if (value.value() == mallocation.address && !value.is_uninitialized()) {
|
|
|
#ifdef REACHABLE_DEBUG
|
|
|
- warnf("mallocation {:p} is reachable from region {:p}-{:p}", mallocation.address, region.base(), region.end() - 1);
|
|
|
+ warnln("mallocation {:p} is reachable from region {:p}-{:p}", mallocation.address, region.base(), region.end() - 1);
|
|
|
#endif
|
|
|
reachable = true;
|
|
|
return IterationDecision::Break;
|
|
@@ -238,14 +238,14 @@ void MallocTracer::dump_leak_report()
|
|
|
continue;
|
|
|
++leaks_found;
|
|
|
bytes_leaked += mallocation.size;
|
|
|
- warnf("\n=={}== \033[31;1mLeak\033[0m, {}-byte allocation at address {:p}", getpid(), mallocation.size, mallocation.address);
|
|
|
+ warnln("\n=={}== \033[31;1mLeak\033[0m, {}-byte allocation at address {:p}", getpid(), mallocation.size, mallocation.address);
|
|
|
Emulator::the().dump_backtrace(mallocation.malloc_backtrace);
|
|
|
}
|
|
|
|
|
|
if (!leaks_found)
|
|
|
- warnf("\n=={}== \033[32;1mNo leaks found!\033[0m", getpid());
|
|
|
+ warnln("\n=={}== \033[32;1mNo leaks found!\033[0m", getpid());
|
|
|
else
|
|
|
- warnf("\n=={}== \033[31;1m{} leak(s) found: {} byte(s) leaked\033[0m", getpid(), leaks_found, bytes_leaked);
|
|
|
+ warnln("\n=={}== \033[31;1m{} leak(s) found: {} byte(s) leaked\033[0m", getpid(), leaks_found, bytes_leaked);
|
|
|
}
|
|
|
|
|
|
}
|