views:

39

answers:

1

My application has custom crash-handling built-in (see John Robbins' excellent book about "Debugging Windows Applications"). To test this functionality, I always used the Windows function DebugBreak() and this always worked perfectly. But since Windows 7, calling this function just says "A breakpoint has been reached" and stops the application without calling my crash handlers.

I could always put this code in my application to test the crash-functionality:

int *ptr = (int *)0xdeadbeef;
*ptr = 123456789;

Or even add several cases, just in case 0xdeadbeef is a valid address:

int *ptr = (int *)0xdeadbeef;
*ptr = 123456789;
ptr = (int *)0L;
*ptr = 123456789;
ptr = (int *)0xffffffff;
*ptr = 123456789;

But I was wondering: isn't there a cleaner way to crash your application under Windows?

A: 

Just create a null pointer to an object with some member functions a try and call one of them? And maybe do it in a function so you know what it daoes

void CrashApp()
{
    MyObject * ptr = 0;
    ptr->Function();
}

Definitely the easiest way and pretty clear whats going on

Tristan