How to match a crash's "Fault offset" to the source code?
Asked Answered
D

1

9

An EXE I compiled keeps crashing. I have the following info in the Event Viewer when it crashes:

Exception code: 0xc0000008
Fault offset: 0x00000000000cb8e8

How do I match the "Fault offset" with my C++ code? There is a .PDB file in the Release folder, just not sure what steps to figure this out.

Deadbeat answered 13/2, 2014 at 20:34 Comment(8)
Why not just use a debugger?Kurys
The exe is at a customer's site.Deadbeat
Again, why not just use a debugger? Most have the ability to take you to the code associated with a specific address.Kurys
Sorry, noob here with no debugging experience unless inside stepping through code in VS! What steps in VS would I use to match the 'Fault offset' with the code? Do I have to send something special to the customer? Do I load something into VS?Deadbeat
And...the exe is a service, so I can't run it from within VS even if the Release version contains debug info.Deadbeat
When you build the EXE check the linker option to generate a map file.Carlinecarling
You can use the dbghelp library to have your program print stack back traces about itself when it crashes.Carlinecarling
You can change your program to generate a dump file on a crash. They send you the dump file and the debugger in your development environment can show you a stack back trace from the EXE and the dump file.Carlinecarling
E
12

You also need to know what module the offset belongs too, if you are getting 0xC0000008 (STATUS_INVALID_HANDLE), then the exception is likely thrown from ntdll.dll, which isn't going to help you debug your program, since what you care about is deeper in the stack.

What you should be doing is have your customer enable LocalDumps, and then send you a minidump file which you can debug.

Sample registry setup:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps]
"DumpFolder"="d:\\miniDumps"
"DumpType"=dword:00000002
"CustomDumpFlags"=dword:00001124
Epanodos answered 13/2, 2014 at 21:22 Comment(4)
Ok...how would I load the mini dump file into VS to debug it?Deadbeat
So I have the dmp file, I dragged it into VS2012, I attached it to the running service process...now what?Deadbeat
can you tell me What vS2012 steps I would take to do that?Deadbeat
I found that I have to have all source code in the Release folder. Then, I have to open it up into VS2012 and hit Run. The program will crash and put me right on the line in my code where it crashed, including variables. Awesome!Deadbeat

© 2022 - 2024 — McMap. All rights reserved.