VirtualBox

Changeset 27293 in vbox for trunk/src


Ignore:
Timestamp:
Mar 11, 2010 4:50:01 PM (15 years ago)
Author:
vboxsync
Message:

Runtime/alloc-ef: more filling and more checking

Location:
trunk/src/VBox/Runtime/r3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/alloc-ef.cpp

    r26258 r27293  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    293293    }
    294294
     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
    295301#ifdef RTALLOC_EFENCE_TRACE
    296302    /*
     
    319325        void *pvEFence = pvBlock;
    320326        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
    321330        #else
    322331        void *pvEFence = (char *)pvBlock + (cbBlock - RTALLOC_EFENCE_SIZE);
    323332        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
    324336        #endif
     337
     338#ifdef RTALLOC_EFENCE_FENCE_FILLER
     339        memset(pvEFence, RTALLOC_EFENCE_FENCE_FILLER, RTALLOC_EFENCE_SIZE);
     340#endif
    325341        int rc = RTMemProtect(pvEFence, RTALLOC_EFENCE_SIZE, RTMEM_PROT_NONE);
    326342        if (!rc)
     
    379395        if (gfRTMemFreeLog)
    380396            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
    381413
    382414    #ifdef RTALLOC_EFENCE_FREE_FILL
  • trunk/src/VBox/Runtime/r3/alloc-ef.h

    r25642 r27293  
    55
    66/*
    7  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4545 * RTMemAllocZ(), RTMemRealloc(), RTMemTmpAlloc() and RTMemTmpAllocZ().
    4646 */
    47 #if 0// defined(DEBUG_bird)
     47#if 1
    4848# define RTALLOC_USE_EFENCE
    4949#endif
     
    8181 * Requires RTALLOC_EFENCE_TRACE.
    8282 */
    83 #if defined(RT_OS_LINUX)
     83#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
    8484# define RTALLOC_EFENCE_FREE_FILL       'f'
    8585#endif
     
    9090 */
    9191#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
    92104
    93105#if defined(DOXYGEN_RUNNING)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette