cdebuggingvisual-studio-2015minidump

Loading .dmp file to locate the error code,but the crash occurs in an unexpected place(in ntdll.dll)


I write a funtion which access a NULL pointer like this:

CORRUPTDLL_API int fncorruptDLL(void)  
{   
    int *p = NULL;   
    printf("%d\n", p[0]);   
    return 0;    
}

and then call this function in main function just like this:

int main()
{
    fncorruptDLL();
    return 0; 
}

As expected,it breaks in the "printf" function and I can clearly see the crash place from the stack frame crash place.

Then I use "Windbg" to create a ".dmp" file and open it with VS2015,start to debug.It turns out a page which shows "No Source Available" page while I have already loaded the correct ".pdb" file and set the source code path like this:set source code path.

Why would this happen?I mean it didn't run into my function,I can just see the crash in "ntdll.dll"(from stack frame).But I am not familiar with assembly language.Does this ".dmp" file really work?

I used the "adplus" to monitor the excutable file

C:\Program Files (x86)\Debugging Tools for Windows (x86)\adplus.exe -crash -pmn winDgb_Test.exe  -FullOnFirst -o D:\VSproject\case-201710\winDgb_Test\Debug\dum

But when the program crashed,it didn't generate any ".dmp" file.What's the problem?


Solution

  • When you start debugging an executable and you start that executable under the debugger (in WinDbg: File / Open Executable), the program will run as short as possible and then stop at the initial breakpoint (MSDN).

    At this time, you can set up your debugger, e.g. define exception behavior, add breakpoints, load extensions, etc. When you're done with that, press g to let the program run. Then reproduce the crash, then create the crash dump.