Click to See Complete Forum and Search --> : Crashing a Managed C++ application


fritzone
March 13th, 2009, 05:36 AM
Hi all,

I've got an interesting task to accomplish, maybe you can help me:

We're developing an application (managed C++ GUI with some native C++ libraries) which has a crash-dump functionality, creates a MiniDump when it crashes. Now I need to write some code which will intentionally crash the application so that it triggers the CrashDump functionality. We also have (mandatory) UnhandledExceptionEventHandlers installed, so that we get the "normal" exceptions. The scope of the crash dump would be to report crashes that are not caught by the handler.

till now I tried:

//int * p = 0; // not deadly enough, gives: System.NullReferenceException: Object reference not set to an instance of an object.
//*p = 0;

// _asm // gives System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
// {
// mov eax, 0
// push eax
// ret
// }

maybe you can help me with this issue, by supplying some code that actually crashed your app.

Thanks a lot
fritzone

cilu
March 14th, 2009, 07:54 PM
Nothing will crash your app if you catch everything. ;) The first exception for which there is no handler in the app will crash it.

Here are some tries:

int crash = 1 / 0;



void free(void* buffer)
{
delete buffer;
}

int main()
{
int a;
free((void*)&a);
}

fritzone
March 16th, 2009, 08:08 AM
Found a solution :)

static void crashMe(int i = 0)
{
DWORD a;
char xx [10000];
Toolhelp32ReadProcessMemory(i, 0, &xx, 20000, &a);
char s[10000];
crashMe(i + 1);
}

Thanks :)

cilu
March 16th, 2009, 05:33 PM
Wow... stack overflow? ;) I wonder how you ended up with this piece of code. ;)

fritzone
March 17th, 2009, 04:01 AM
Hey, I Tried all kind of "solutions" till I've found on the almighty internet that .NET (from 2.0) does not allow you to catch Stack Overflows :( from this point it was easy to implement it ... but now we have another problem. Since by design, .NET does not allow you to catch this Stack Overflow exception our crash handler does not get called ... so now we are back to the situation, on How to catch an uncatcheable Stack Overflow Exception :(