写DUMP文件吧,然后用windbg来分析
我以前用这几个API也遇见过一样的问题,没有解决,最后用写dump的方法来搞的

解决方案 »

  1.   

    你好,谢谢你第一个回复,其实Dump文件产生了同样的问题,我通过MiniDumpWriteDump函数来写dump文件,异常程序死机后,产生出.dmp文件。
    我下载了WinDbg软件(版本:WinDbg:6.11.0001.404.X86),设置了pdb文件路径为我VC的*.pdb文件路径(其实就是VC的Output路径),然后在windbg中OpenFile--》Open Crash Dump,下面就是结果:This dump file has an exception of interest stored in it.
    The stored exception information can be accessed via .ecxr.
    (145c.140c): Access violation - code c0000005 (first/second chance not available)
    eax=00000066 ebx=0016df30 ecx=00000010 edx=0002dbe0 esi=0016df08 edi=0016df60
    eip=7c92e514 esp=09efecc4 ebp=09efecd4 iopl=0         nv up ei pl zr na pe nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdll.dll - 
    ntdll!KiFastSystemCallRet:
    7c92e514 c3              ret结果报错:ERROR: Symbol file could not be found麻烦再帮助看看,如何解决。
      

  2.   

    *** ERROR: Symbol file could not be found. Defaulted to export symbols for ntdll.dll
     --- 这是你的ntdll.dll对应的PDB文件没有!
      

  3.   

    谢谢,你的回复,前几天出差去现场解决问题,没有及时回帖请谅解。
    问题还是没有解决。
    当前已经设置了,symbol的路径为:D:\Windows\XP\Symbols\dll;E:\Code\MASU 0509\publib
    其中D:\Windows\XP\Symbols\dll为我从微软网站下载的symbols大包,然后open dump得到:
    Unable to deliver callback, Unable to deliver callback, 00
    WARNING: Whitespace at start of path element
    WARNING: Non-directory path: 'WARNING: Non-directory path: 'E:\Code\MASU 0509\publib\masud.pdbE:\Code\MASU 0509\publib\masud.pdb'
    '
    Loading Dump File [E:\Code\MASU 0509\publib\masud.dmp]
    Loading Dump File [E:\Code\MASU 0509\publib\masud.dmp]
    User Mini Dump File: Only registers, stack and portions of memory are available
    User Mini Dump File: Only registers, stack and portions of memory are available
    WARNING: Non-directory path: 'WARNING: Non-directory path: 'E:\Code\MASU 0509\publib\masud.pdbE:\Code\MASU 0509\publib\masud.pdb'
    '
    Symbol search path is: Symbol search path is: E:\Code\MASU 0509\publib\;D:\Windows\XP\Symbols\dll\;E:\Code\MASU 0509\publib
    E:\Code\MASU 0509\publib\;D:\Windows\XP\Symbols\dll\;E:\Code\MASU 0509\publib
    Executable search path is: E:\Code\MASU 0509\publib\masud.pdb
    Executable search path is: E:\Code\MASU 0509\publib\masud.pdb
    Windows XP Windows XP Version 2600Version 2600 (Service Pack 3) (Service Pack 3) MP  MP (2 procs) (2 procs) Free x86 compatible
    Free x86 compatible
    Product: Product: WinNtWinNt, suite:, suite: SingleUserTS SingleUserTS
    Machine Name:Machine Name:
    Debug session time: Tue Jun  7 18:06:54.000 2011 (GMT+8)
    Debug session time: Tue Jun  7 18:06:54.000 2011 (GMT+8)
    System Uptime: not available
    System Uptime: not available
    Process Uptime: 0 days 0:00:02.000
    Process Uptime: 0 days 0:00:02.000
    ................................................................................................................................
    ......................................
    Unable to deliver callback, Unable to deliver callback, 127127
    This dump file has an exception of interest stored in it.
    The stored exception information can be accessed via .ecxr.
    This dump file has an exception of interest stored in it.
    The stored exception information can be accessed via .ecxr.
    (9cc.8f0): Access violation(9cc.8f0): Access violation - code c0000005 (first/second chance not available)
     - code c0000005 (first/second chance not available)
    eax=07030000 ebx=0016e290 ecx=00000007 edx=7c92e514 esi=0016e268 edi=0016e2c0
    eip=7c92e514 esp=08fbecc4 ebp=08fbecd4 iopl=0         nv up ei pl zr na pe nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246
    eax=07030000 ebx=0016e290 ecx=00000007 edx=7c92e514 esi=0016e268 edi=0016e2c0
    eip=7c92e514 esp=08fbecc4 ebp=08fbecd4 iopl=0         nv up ei pl zr na pe nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000246
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdll.dll - 
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdll.dll - 
    ntdll!KiFastSystemCallRet:
    7c92e514 c3              ret
    ntdll!KiFastSystemCallRet:
    7c92e514 c3              ret
    不明白,为什么有这样的warning:
    WARNING: Non-directory path: 'WARNING: Non-directory path: 'E:\Code\MASU 0509\publib\masud.pdbE:\Code\MASU 0509\publib\masud.pdb'
     
    然后我通过楼上的命令:!analyze -v得到:
    FAULTING_IP: 
    MSVCRTD!strcat+81
    FAULTING_IP: 
    MSVCRTD!strcat+81
    10218fe1 8917            mov     dword ptr [edi],edx
    10218fe1 8917            mov     dword ptr [edi],edx
    EXCEPTION_RECORD: 
    EXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff)
     ffffffff -- (.exr 0xffffffffffffffff)
    ExceptionAddress: 10218fe1 (MSVCRTD!strcat+0x00000081)
       ExceptionCode: c0000005 (Access violation)
      ExceptionFlags: 00000000
    NumberParameters: 2
       Parameter[0]: 00000001
       Parameter[1]: 00000000
    Attempt to write to address 00000000
    ExceptionAddress: 10218fe1 (MSVCRTD!strcat+0x00000081)
       ExceptionCode: c0000005 (Access violation)
      ExceptionFlags: 00000000
    NumberParameters: 2
       Parameter[0]: 00000001
       Parameter[1]: 00000000
    Attempt to write to address 00000000
    PROCESS_NAME:  masud.exe
    ADDITIONAL_DEBUG_TEXT:  
    Use '!findthebuild' command to search for the target build information.
    If the build information is available, run '!findthebuild -s ; .reload' to set symbol path and load symbols.
    MODULE_NAME: 
    PROCESS_NAME:  masud.exe
    ADDITIONAL_DEBUG_TEXT:  
    Use '!findthebuild' command to search for the target build information.
    If the build information is available, run '!findthebuild -s ; .reload' to set symbol path and load symbols.
    MODULE_NAME: MSVCRTD
    MSVCRTD
    FAULTING_MODULE: 
    FAULTING_MODULE: 7c920000 ntdll
    7c920000 ntdll
    DEBUG_FLR_IMAGE_TIMESTAMP:  4032061e
    ERROR_CODE: (NTSTATUS) 0xc0000005 - "0x%08lx"
    EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - "0x%08lx"
    EXCEPTION_PARAMETER1:  00000001
    EXCEPTION_PARAMETER2:  00000000
    WRITE_ADDRESS:  00000000 
    FOLLOWUP_IP: 
    MSVCRTD!strcat+81
    DEBUG_FLR_IMAGE_TIMESTAMP:  4032061e
    ERROR_CODE: (NTSTATUS) 0xc0000005 - "0x%08lx"
    EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - "0x%08lx"
    EXCEPTION_PARAMETER1:  00000001
    EXCEPTION_PARAMETER2:  00000000
    WRITE_ADDRESS:  00000000 
    FOLLOWUP_IP: 
    MSVCRTD!strcat+81
    10218fe1 8917            mov     dword ptr [edi],edx
    10218fe1 8917            mov     dword ptr [edi],edx
    FAULTING_THREAD:  000008f0
    BUGCHECK_STR:  APPLICATION_FAULT_NULL_POINTER_READ_NULL_POINTER_WRITE_WRONG_SYMBOLS_FILL_PATTERN_31313131
    PRIMARY_PROBLEM_CLASS:  NULL_POINTER_READ_FILL_PATTERN_31313131
    DEFAULT_BUCKET_ID:  NULL_POINTER_READ_FILL_PATTERN_31313131
    LAST_CONTROL_TRANSFER:  from 00e479c6 to 10218fe1
    STACK_TEXT:  
    WARNING: Stack unwind information not available. Following frames may be wrong.
    08fbff5c 00e479c6 7ffd5000 00000000 0681f798 MSVCRTD!strcat+0x81
    08fbffb4 7c80b729 0681f798 7ffd5000 00000000 dvrLink_d!DVRBridgeThreadProc+0x26 [e:\code\masu 0509\dvrlink\src\dvrmanager.cpp @ 28]
    08fbffec 00000000 00d72739 0681f798 00000000 kernel32!GetModuleFileNameA+0x1ba
    SYMBOL_STACK_INDEX:  0
    SYMBOL_NAME:  MSVCRTD!strcat+81
    FOLLOWUP_NAME:  MachineOwner
    IMAGE_NAME:  MSVCRTD.DLL
    STACK_COMMAND:  ~34s; .ecxr ; kb
    BUCKET_ID:  WRONG_SYMBOLS
    FAILURE_BUCKET_ID:  NULL_POINTER_READ_FILL_PATTERN_31313131_c0000005_MSVCRTD.DLL!strcat
    WATSON_STAGEONE_URL:  
    FAULTING_THREAD:  000008f0
    BUGCHECK_STR:  APPLICATION_FAULT_NULL_POINTER_READ_NULL_POINTER_WRITE_WRONG_SYMBOLS_FILL_PATTERN_31313131
    PRIMARY_PROBLEM_CLASS:  NULL_POINTER_READ_FILL_PATTERN_31313131
    DEFAULT_BUCKET_ID:  NULL_POINTER_READ_FILL_PATTERN_31313131
    LAST_CONTROL_TRANSFER:  from 00e479c6 to 10218fe1
    STACK_TEXT:  
    WARNING: Stack unwind information not available. Following frames may be wrong.
    08fbff5c 00e479c6 7ffd5000 00000000 0681f798 MSVCRTD!strcat+0x81
    08fbffb4 7c80b729 0681f798 7ffd5000 00000000 dvrLink_d!DVRBridgeThreadProc+0x26 [e:\code\masu 0509\dvrlink\src\dvrmanager.cpp @ 28]
    08fbffec 00000000 00d72739 0681f798 00000000 kernel32!GetModuleFileNameA+0x1ba
    SYMBOL_STACK_INDEX:  0
    SYMBOL_NAME:  MSVCRTD!strcat+81
    FOLLOWUP_NAME:  MachineOwner
    IMAGE_NAME:  MSVCRTD.DLL
    STACK_COMMAND:  ~34s; .ecxr ; kb
    BUCKET_ID:  WRONG_SYMBOLS
    FAILURE_BUCKET_ID:  NULL_POINTER_READ_FILL_PATTERN_31313131_c0000005_MSVCRTD.DLL!strcat
    WATSON_STAGEONE_URL:  http://watson.microsoft.com/StageOne/masud_exe/0_0_0_0/4dedf83b/MSVCRTD_DLL/6_0_9782_0/4032061e/c0000005/00018fe1.htm?Retriage=1
    Followup: MachineOwner
    ---------
    http://watson.microsoft.com/StageOne/masud_exe/0_0_0_0/4dedf83b/MSVCRTD_DLL/6_0_9782_0/4032061e/c0000005/00018fe1.htm?Retriage=1
    Followup: MachineOwner
    其中最关键的地方在于:
    STACK_TEXT:  
    WARNING: Stack unwind information not available. Following frames may be wrong.
    08fbff5c 00e479c6 7ffd5000 00000000 0681f798 MSVCRTD!strcat+0x81
    08fbffb4 7c80b729 0681f798 7ffd5000 00000000 dvrLink_d!DVRBridgeThreadProc+0x26 [e:\code\masu 0509\dvrlink\src\dvrmanager.cpp @ 28]
    08fbffec 00000000 00d72739 0681f798 00000000 kernel32!GetModuleFileNameA+0x1ba
    其中我死机的地方如何用以上信息定位:DVRBridgeThreadProc+0x26 [e:\code\masu 0509\dvrlink\src\dvrmanager.cpp @ 28]
    估计造成死机的代码为:
     
    DWORD WINAPI  DVRBridgeThreadProc(LPVOID lpParameter)
    {
        CDVRManager *pThread;
        pThread = (CDVRManager *)lpParameter;
        pThread->Execute();
        ExitThread(0);
        return 1;
    }
    int CDVRManager::Execute(void)
    {
        int     iChannelNum = m_pMainData->m_pConfigInfo->iChannelNum;
        DVRCHANNELINFO  *pChannelInfo;
        char* szTmpBuf = NULL;
    strcpy(szTmpBuf, "1111");/*在这里0地址访问,造成死机*/
        while(!m_Terminated)
        {
            。
     
        }
    }
    若是我哪里没有写清楚,麻烦及时提问,谢谢各位windows系统高手。
      

  4.   

    char* szTmpBuf = NULL;
    strcpy(szTmpBuf, "1111");/*在这里0地址访问,造成死机*/
    你都没分配内存,如何拷贝字符串啊?
      

  5.   

    天啦,都找到
      char* szTmpBuf = NULL;
    strcpy(szTmpBuf, "1111");/*在这里0地址访问,造成死机*/
    这里,还问是什么问题
      

  6.   

    楼上的三位专家,就不要玩我了。
    char* szTmpBuf = NULL;
    strcpy(szTmpBuf, "1111");/*在这里0地址访问,造成死机*/
    这种零地址改写,大街上随便找个人都能看出来啊!这个代码当然是用于实验。
    估计是没有看我的问题。请教windows系统级专家,我问的问题是:
    应用dbghelp.DLL捕捉到异常后,生成了dump文件,如何用dump文件通过windbg工具和符号表来定位windows程序死机的位置。
    现在用windbg工具打开了dump文件,并且制定了符号表文件路径。应执行了!analyze -v的命令,仍旧不能通过符号表得出对应死机的行数。
    得出的知识机器码的偏移:DVRBridgeThreadProc+0x26 
    因为符号表没有发挥作用。(可以看看我操作步骤的描述)所以这里请教windows系统级专家,如何通过dump文件、符号表来定位问题出现的行数。
    这个问题在这个论坛出现个多次,始终没有解答,麻烦有高手终结!
      

  7.   

    Dump文件还要要结合你工程中编译生成的pdb文件,这样才能定位源代码中出错的行~
      

  8.   

    http://jianhai1229.blog.163.com/blog/static/34887000200861041311981/
    参考一下这个,希望对你有帮助~
      

  9.   

    如果是使用vs2010,则在工程配置里面选择“链接器”--输入--附加依赖项,添加DbgHelp.Lib;
    如此即可!
    因为我也出现了这个问题,所以经过了测试,这个方法可行。