add_wall() first added the memory block to the list, and then added the wall - there

was a race condition between that and the wall checker daemon (if enabled): it could
occasionally report an overwritten wall in that very moment.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14051 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-08-22 21:01:03 +00:00
parent 5793da1edc
commit 19dfa58852

View File

@ -224,14 +224,13 @@ add_wall(void *address, size_t size, size_t alignment)
address = (uint8 *)address + alignment;
wall = get_wall(address);
set_wall(wall, size, alignment);
#if USE_CHECKING_WALL
acquire_sem(sWallCheckLock);
list_add_link_to_tail(&sWalls, &wall->link);
release_sem(sWallCheckLock);
#endif
set_wall(wall, size, alignment);
return address;
}
@ -246,8 +245,8 @@ check_wall(void *address)
for (i = 0; i < WALL_SIZE / 4; i++) {
if (frontWall->wall[i] != 0xabadcafe) {
panic("free: front wall %i was overwritten (allocation at %p, %lu bytes): %08lx\n",
i, address, frontWall->size, frontWall->wall[i]);
panic("free: front wall %i (%p) was overwritten (allocation at %p, %lu bytes): %08lx\n",
i, frontWall, address, frontWall->size, frontWall->wall[i]);
}
}
@ -255,8 +254,8 @@ check_wall(void *address)
for (i = 0; i < WALL_SIZE / 4; i++) {
if (backWall->wall[i] != 0xabadcafe) {
panic("free: back wall %i was overwritten (allocation at %p, %lu bytes): %08lx\n",
i, address, frontWall->size, backWall->wall[i]);
panic("free: back wall %i (%p) was overwritten (allocation at %p, %lu bytes): %08lx\n",
i, backWall, address, frontWall->size, backWall->wall[i]);
}
}
}