To handle Vectored Exceptions with Crashpad, one does need to do the following:

  1. Integrate Crashpad

  2. Create a handler function with the following signature:

  3. Register the global exception handler, or use the handler in a __try /__except  block.

Useful Exception codes

  • 0xC0000005 - Access Violation

  • 0xE06D7363 - External Exception

  • 0xC0000374 - Heap Corruption

  • 0xC000008E - Float Divide By Zero

  • 0xC0000094  - Integer Divide By Zero

  • 0xC000001D - Illegal Instruction

Integrating Crashpad

This step is described in this help article.

Creating the handler function

MSDN contains the documentation. An example function handling Access Violation errors (0xC0000005 ).

LONG WINAPI VectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo)
    // Access Violation
    if (pExceptionInfo->ExceptionRecord->ExceptionCode == 0xC0000005) {
        // CrashpadClient client;
        // The client is already initialized, you can look at the
        // integration article for an example



Registering the handler function

This is done by the AddVectoredExceptionHandler function:

AddVectoredExceptionHandler(0, &::VectoredExceptionHandler);

Using the __try/__except block

Pass the handler function as an argument to __except . Feed it PEXCEPTION_POINTERS  from GetExceptionInformation() :

__try {
    memset(nullptr, 42, 2000000);
__except (VectoredExceptionHandler(GetExceptionInformation()))
    printf("all is good\n");

The result

If the necessary symbols have been uploaded, the uploaded minidump should contain the necessary information about the callstack, if at all possible. There are certain error scenarios, i.e. stack smashing, that render this impossible.

Did this answer your question?