mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:18:13 +00:00
UserspaceEmulator: Log invalid and double free() calls :^)
We can easily catch free() on never-malloced addresses, as well as double calls to free() on the same address, so let's do it!
This commit is contained in:
parent
4aa81a4fd9
commit
092f643119
1 changed files with 10 additions and 1 deletions
|
@ -51,11 +51,20 @@ void MallocTracer::target_did_free(Badge<SoftCPU>, FlatPtr address)
|
|||
{
|
||||
for (auto& mallocation : m_mallocations) {
|
||||
if (mallocation.address == address) {
|
||||
if (mallocation.freed) {
|
||||
dbgprintf("\n");
|
||||
dbgprintf("==%d== \033[31;1mDouble free()\033[0m, %p\n", s_pid, address);
|
||||
dbgprintf("==%d== Address %p has already been passed to free()\n", s_pid, address);
|
||||
Emulator::the().dump_backtrace();
|
||||
}
|
||||
mallocation.freed = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
dbgprintf("\n");
|
||||
dbgprintf("==%d== \033[31;1mInvalid free()\033[0m, %p\n", s_pid, address);
|
||||
dbgprintf("==%d== Address %p has never been returned by malloc()\n", s_pid, address);
|
||||
Emulator::the().dump_backtrace();
|
||||
}
|
||||
|
||||
MallocTracer::Mallocation* MallocTracer::find_mallocation(FlatPtr address)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue