1

I have a large-ish Win32 program that I'm maintaining, and I'd like to instrument it to automatically and unconditionally generate a minidump file whenever something bad happens. I can't ask customers to install userdump.exe, and I can't ask them to install visual studio.

Is there a good way of doing this? I'd like to be able to generate a minidump whether abort() is called from our assert handler (which is complicated), whether someone touches bad memory, or anything else really bad happens.

On Posix, I'd install a signal handler and be done with this. My understanding is that the equivalent approach on Windows is SEH, but our program starts up a lot of threads in a lot of different places so it would be very painful to wrap every thread entry point with a __try/__catch.

Ideas?

Ted Middleton
  • 6,859
  • 10
  • 51
  • 71
  • 1
    http://msdn.microsoft.com/en-us/library/windows/desktop/ms680634%28v=vs.85%29.aspx – Hans Passant Jun 19 '14 at 23:48
  • @HansPassant: That's exactly what I was looking for! Thank you! Post this as an answer and I'll add the green check mark. – Ted Middleton Jun 20 '14 at 01:30
  • `SetUnhandledExceptionFilter` does not catch things as an `abort`, which happens on MSVC when you call a mutex in a invalid state. For an alternative, see: https://www.codeproject.com/Articles/207464/Exception-Handling-in-Visual-Cplusplus – Evandro Coan May 10 '21 at 05:22

1 Answers1

1

There are google breakpad client and server components for catching crashes. You could use this lib

Also you could register your filter(could check for different expedition types ) callback for handling exceptions using AddVectoredExceptionHandler.

I hope it helped

Yuriy Pryyma
  • 574
  • 6
  • 18