Exception / stack problem (VC++ 6.0)
Posted on 2004-03-21
I need to test what happens when I cause a stack overflow, so I wrote this tiny test:
void * pMem0 = _alloca(0xFFFFFFFF);
memset(pMem0, 0, 0xFFFFFFFF);
MessageBox(NULL, "Exception!", "Exception", MB_OK);
From the theory, I cannot allocate 0xFFFFFFFF on the stack on a 32 Bit machine. But I get no exception in this line ! Without the "memset" operation, the program runs through without any problem. Strange.
So I took the "memset" operation after the alloca, and now I am told "Unhandled Exception in Test.exe". Even more strange! I have an exception handler, I tried alternatively with "normal try/catch", but to the same result. "Enable exception handling" is switched on. I even set the /F0x64 switch just to make sure that I have a small stack, but to the same result.
So I have two questions:
1) Why doesn't my _alloca call cause any exception ?
2) Why is the memset exception not caught by my handler ?