0

We've added code to generate a minidump in our C++ 32 bit service. The dump file is successfully created with MiniDumpWriteDump. When I open the file with Visual Studio 2017 and run I can see all the threads but the stack traces only contain Windows DLLs like ntdll.dll and kernel.dll. There are no references to our modules except lines starting with [inline].

The exception pointers are from our exception handling code, using ::SetUnhandledExceptionFilter. We have a 2nd file that is just a crash log or the thread that has the exception using the same exception pointers object and it has the full stack.

Note: This is older code and some of it is using MFC. We're phasing that out over time.

Ðаn
  • 10,934
  • 11
  • 59
  • 95
James S
  • 1
  • 2
  • 2
    Can Visual Studio see your .pdb file(s) (as well as your executable(s))? – Paul Sanders Feb 13 '20 at 18:48
  • 1
    Please show how you are generating the dump files. There are lots of knobs you can turn, and some of them cause Visual Studio to fail to make sense of them. Also, try to open the minidump in WinDbg to see if this is an issue with your code, or with Visual Studio. – IInspectable Feb 13 '20 at 23:44
  • Visual Studio can see the binaries and PDB files. To work on this issue I'm causing an access violation exception with a string copy to a NULL pointer. We ended up implementing the solution found in this [post](https://stackoverflow.com/questions/32691914/access-violation-in-minidumpwritedump-when-invoked-out-of-process?lq=1). Our code is almost identical except that I've tried various dump flag combinations. Interestingly, I found an old dbghelp.dll and lib file (version 5) and I do get a proper stack dump without changing any code. – James S Feb 14 '20 at 22:42
  • https://stackoverflow.com/questions/32691914/access-violation-in-minidumpwritedump-when-invoked-out-of-process?lq=1 – James S Feb 14 '20 at 22:43
  • I've made a little progress. For debugging purposes we wrote our services to also run as a standard EXE. When I run as standard EXE I get the full stack traces and source code. So this seems to be a permissions thing. Our services run under "Local System", the default log on. I've tried other user accounts and get the same missing stack and source code. Any idea how this services should be configured? – James S Feb 15 '20 at 16:00
  • Why don't you let Windows Error Reporting do this for you? [Collecting User-Mode Dumps](https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps) explains how to set this up. It boils down to setting some registry values. – IInspectable Feb 15 '20 at 23:12
  • Thanks, I found the user-mode dump link yesterday. I just figured out why I couldn't get it to work. Our code is using SetUnhandledExceptionFilter to create a detailed log file that is actually quite handy. If I comment out that handler I then get a user-mode dump. Ideally, I'd like both and need to figure out why the stack traces are incomplete with our own handler. I'll keep digging. – James S Feb 17 '20 at 15:17
  • I believe I've found the issue. The aforementioned handy crash log that also gets generated calls StackWalk in the DbgHelp.dll to get the problem stack trace. It looks like calling this moves some kind of index and the minidump starts at the end of the stack trace. I need to find a way to reset the stack pointer to the top when the log is done. Thanks for your help everyone. – James S Feb 18 '20 at 18:44
  • To help others using StackWalk, I made a copy of the CONTEXT pointer before starting the stack walk. At the end I copied the context back into the pointer. – James S Feb 18 '20 at 19:53

0 Answers0