- Timestamp:
- Mar 11, 2010 4:50:01 PM (15 years ago)
- Location:
- trunk/src/VBox/Runtime/r3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/alloc-ef.cpp
r26258 r27293 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Sun Microsystems, Inc.7 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 293 293 } 294 294 295 /** @todo this alignment decreases fence accuracy, but there are lots 296 * of places in VirtualBox which assumes that the allocation is aligned 297 * properly even for totally unusual allocation sizes, otherwise assertions 298 * are triggered, which ensure a particular alignment of elements. */ 299 cb = RT_ALIGN_Z(cb, ARCH_BITS / 8); 300 295 301 #ifdef RTALLOC_EFENCE_TRACE 296 302 /* … … 319 325 void *pvEFence = pvBlock; 320 326 void *pv = (char *)pvEFence + RTALLOC_EFENCE_SIZE; 327 #ifdef RTALLOC_EFENCE_NOMAN_FILLER 328 memset((char *)pv + cb, RTALLOC_EFENCE_NOMAN_FILLER, PAGE_SIZE - cb % PAGE_SIZE); 329 #endif 321 330 #else 322 331 void *pvEFence = (char *)pvBlock + (cbBlock - RTALLOC_EFENCE_SIZE); 323 332 void *pv = (char *)pvEFence - cb; 333 #ifdef RTALLOC_EFENCE_NOMAN_FILLER 334 memset(pvBlock, RTALLOC_EFENCE_NOMAN_FILLER, cbBlock - RTALLOC_EFENCE_SIZE - cb); 335 #endif 324 336 #endif 337 338 #ifdef RTALLOC_EFENCE_FENCE_FILLER 339 memset(pvEFence, RTALLOC_EFENCE_FENCE_FILLER, RTALLOC_EFENCE_SIZE); 340 #endif 325 341 int rc = RTMemProtect(pvEFence, RTALLOC_EFENCE_SIZE, RTMEM_PROT_NONE); 326 342 if (!rc) … … 379 395 if (gfRTMemFreeLog) 380 396 RTLogPrintf("RTMem %s: pv=%p pvCaller=%p cb=%#x\n", pszOp, pv, pvCaller, pBlock->cb); 397 398 #ifdef RTALLOC_EFENCE_NOMAN_FILLER 399 /* 400 * Check whether the no man's land is untouched. 401 */ 402 # ifdef RTALLOC_EFENCE_IN_FRONT 403 void *pvNoMan = (char *)pv + pBlock->cb; 404 # else 405 void *pvNoMan = (void *)((uintptr_t)pv & ~PAGE_OFFSET_MASK); 406 # endif 407 void *p = ASMMemIsAll8(pvNoMan, 408 RT_ALIGN_Z(pBlock->cb, PAGE_SIZE) - pBlock->cb, 409 RTALLOC_EFENCE_NOMAN_FILLER); 410 if (p) 411 RTAssertDoPanic(); 412 #endif 381 413 382 414 #ifdef RTALLOC_EFENCE_FREE_FILL -
trunk/src/VBox/Runtime/r3/alloc-ef.h
r25642 r27293 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Sun Microsystems, Inc.7 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 45 45 * RTMemAllocZ(), RTMemRealloc(), RTMemTmpAlloc() and RTMemTmpAllocZ(). 46 46 */ 47 #if 0// defined(DEBUG_bird)47 #if 1 48 48 # define RTALLOC_USE_EFENCE 49 49 #endif … … 81 81 * Requires RTALLOC_EFENCE_TRACE. 82 82 */ 83 #if defined(RT_OS_LINUX) 83 #if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) 84 84 # define RTALLOC_EFENCE_FREE_FILL 'f' 85 85 #endif … … 90 90 */ 91 91 #define RTALLOC_EFENCE_FILLER 0xef 92 93 /** @def RTALLOC_EFENCE_NOMAN_FILLER 94 * This define will enable memset(,RTALLOC_EFENCE_NOMAN_FILLER,)'ing the 95 * unprotected but not allocated area of memory, the so called no man's land. 96 */ 97 #define RTALLOC_EFENCE_NOMAN_FILLER 0xaa 98 99 /** @def RTALLOC_EFENCE_FENCE_FILLER 100 * This define will enable memset(,RTALLOC_EFENCE_FENCE_FILLER,)'ing the 101 * fence itself, as debuggers can usually read them. 102 */ 103 #define RTALLOC_EFENCE_FENCE_FILLER 0xcc 92 104 93 105 #if defined(DOXYGEN_RUNNING)
Note:
See TracChangeset
for help on using the changeset viewer.