VirtualBox

Changeset 105556 in vbox


Ignore:
Timestamp:
Aug 1, 2024 9:59:44 AM (8 weeks ago)
Author:
vboxsync
Message:

VBoxDbg: Some more ntrbtree checks. bugref:10727

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/DBGCNtCommands.cpp

    r105538 r105556  
    7575{
    7676    uint64_t Root;  /**< Address of the root node (NT_RTL_BALANCED_NODE64). */
    77     uint64_t Min;   /**< Address of the left most node (NT_RTL_BALANCED_NODE64). */
     77    /** The address of the left-most node (NT_RTL_BALANCED_NODE64).
     78     *  Bit 0 is used to indicate 'Encoded', meaning that Left and Right are
     79     *  XORed with the node address and Min is XORed with the address of this
     80     *  structure. */
     81    uint64_t Min;
    7882} NT_RTL_RB_TREE64;
    7983
     
    97101int dbgCmdNtRbTreeWorker(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PCDBGCVAR pRootAddr)
    98102{
     103    int           rcRet          = VINF_SUCCESS;
     104    uint32_t      cErrors        = 0;
    99105    PtrType const fAlignMask     = ~(PtrType)(sizeof(PtrType) - 1);
    100106    PtrType const fAlignInfoMask =  (PtrType)(sizeof(PtrType) - 1);
     
    110116    DBGCCmdHlpPrintf(pCmdHlp,
    111117                     sizeof(PtrType) == sizeof(uint64_t)
    112                      ? "RB Root %DV: Root=%#016RX64 Min=%#016RX64\n"
    113                      : "RB Root %DV: Root=%#010RX32 Min=%#010RX32\n",
    114                      pRootAddr, Root.Root, Root.Min);
     118                     ? "RB Root %DV: Root=%#016RX64 Min=%#016RX64%s\n"
     119                     : "RB Root %DV: Root=%#010RX32 Min=%#010RX32%s\n",
     120                     pRootAddr, Root.Root, Root.Min, Root.Min & 1 ? " Encoded=1" : "");
    115121    if ((Root.Root & fAlignMask) == 0 || (Root.Min & fAlignMask) == 0)
    116122    {
     
    120126            DBGCCmdHlpPrintf(pCmdHlp, "RB Root %DV: Bogus root state!\n", pRootAddr);
    121127        return VINF_SUCCESS;
     128    }
     129    if (Root.Root & fAlignInfoMask)
     130    {
     131        rcRet = DBGCCmdHlpFail(pCmdHlp, pCmd, "Misaligned Root pointer: %#RX64", Root.Root);
     132        cErrors++;
     133    }
     134    if ((Root.Min & fAlignInfoMask) > 1)
     135    {
     136        rcRet = DBGCCmdHlpFail(pCmdHlp, pCmd, "Misaligned Min pointer: %#RX64 (bits 1+ should be zero)", Root.Min);
     137        cErrors++;
    122138    }
    123139
     
    153169    cStackEntries++;
    154170
    155     int      rcRet       = VINF_SUCCESS;
    156171    uint8_t  cReqBlacks  = 0; /**< Number of black nodes required in each path. Set when we reach the left most node. */
    157172    uint8_t  cchMaxDepth = 32;
    158173    uint32_t idxNode     = 0;
    159     uint32_t cErrors     = 0;
    160174    while (cStackEntries > 0)
    161175    {
     
    222236                    cchMaxDepth = RT_MIN(cReqBlacks * 4, RT_ELEMENTS(aStack) * 2 + 2);
    223237
    224                     if (Root.Min != aStack[idxCurEntry].Ptr)
     238                    if ((Root.Min & ~(PtrType)1) != aStack[idxCurEntry].Ptr)
    225239                    {
    226240                        rcRet = DBGCCmdHlpFail(pCmdHlp, pCmd,
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