Re: !htrace 开启栈跟踪后不能正常显示栈

WinDbg

!htrace 开启栈跟踪后不能正常显示栈


qstesiro 2015-01-02, 15:56 下午
使用!htrace检测句柄泄露问题,但是在开启动后发现打印出的栈都是一些无效的内容,具体如下:

void HandleTest()
{
        int i = 0; 
        HANDLE hevent = NULL;
        HANDLE hmutex = NULL;

        for (i = 0; i < 5; ++i)
        {
               hevent = CreateEvent(NULL, FALSE, FALSE, NULL);
        }

        for (i = 0; i < 5; ++i)
        {
              hmutex = CreateMutex(NULL, FALSE, NULL);
        }
}

在执行此函数之前,使用 !htrace -enable 命令,执行完后执行 !htrace 列表记录的所有句柄,但是显示如下(没有全部列出):

0:000> !htrace                                 
--------------------------------------         
Handle = 0x00000090 - OPEN                     
Thread ID = 0x0000191c, Process ID = 0x00001bf4
                                               
0x04723a90: +0x04723a90                        
0x0447de53: +0x0447de53                        
0x0009bc9a: +0x0009bc9a                        
--------------------------------------         
Handle = 0x0000008c - OPEN                     
Thread ID = 0x0000191c, Process ID = 0x00001bf4
                                               
0x04723a90: +0x04723a90                        
0x0447de53: +0x0447de53                        
0x0009bc9a: +0x0009bc9a                        
--------------------------------------         
Handle = 0x00000088 - OPEN                     
Thread ID = 0x0000191c, Process ID = 0x00001bf4
                                               
0x04723a90: +0x04723a90                        
0x0447de53: +0x0447de53                        
0x0009bc9a: +0x0009bc9a                        
--------------------------------------         
Handle = 0x00000084 - OPEN                     
Thread ID = 0x0000191c, Process ID = 0x00001bf4
                                               
0x04723a90: +0x04723a90                        
0x0447de53: +0x0447de53                        
0x0009bc9a: +0x0009bc9a                        
--------------------------------------         
Handle = 0x00000080 - OPEN                     
Thread ID = 0x0000191c, Process ID = 0x00001bf4
                                               
0x04723a90: +0x04723a90                        
0x0447de53: +0x0447de53                        
0x0009bc9a: +0x0009bc9a     

查看具体的句柄信息是没有问题的:

0:000> !handle 0x0000008c f                          
Handle 8c                                            
  Type          Mutant                               
  Attributes    0                                    
  GrantedAccess 0x1f0001:                            
         Delete,ReadControl,WriteDac,WriteOwner,Synch
         QueryState                                  
  HandleCount   2                                    
  PointerCount  3                                    
  Name          <none>                               
  Object Specific Information                        
    Mutex is Free                                    

查看栈地址都是无效地址:

0:000> db 0x04723a90                                                       
04723a90  ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ??  ????????????????
04723aa0  ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ??  ????????????????
04723ab0  ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ??  ????????????????
04723ac0  ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ??  ????????????????
04723ad0  ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ??  ????????????????
04723ae0  ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ??  ????????????????
04723af0  ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ??  ????????????????
04723b00  ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ??  ????????????????
0:000> u 0x04723a90                                                        
04723a90 ??              ???                                               
                  ^ Memory access error in 'u 0x04723a90'   
0:000> ln 0x04723a90 
0:000>               
               
请大家帮忙看看,环境:win7 (x64)、cdb (6.12.0002.633 X86),VS2010, 程序是x86                   

Re: !htrace 开启栈跟踪后不能正常显示栈


navono 2015-09-08, 10:03 上午
我也遇到了这个问题。lmvm打印出的信息显示所有的pdb都已经加载了。而且kbn显示都可以。就是!htrace -diff显示的都是虚地址。

Powered by Community Server Powered by CnForums.Net