I am confused

Started by
10 comments, last by griffin2000 17 years, 9 months ago
I get some exception error code in debug mode. "First-chance exception at 0x0055ca40 in Laby.exe: 0xC0000094: Integer division by zero." The first error is integer devision by zero. However, I explictly made my program catch all windows exception. And if I intentionally divide by zero it catchs it. Why it doesnt catch this devision by zero? And what "is exception at 0x0055ca40"? Thanks in advance.

'Laby.exe': Loaded 'E:\Projects\Engine2\V0\Laby\Debug\Laby.exe', Symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\dbghelp.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\d3d9.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\d3d8thk.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\dinput8.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\dsound.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\lpk.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\usp10.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\msctf.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\CTAGENT.DLL', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\hid.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\setupapi.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\wintrust.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\crypt32.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\msasn1.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\imagehlp.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\ntmarta.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\wldap32.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\samlib.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\wdmaud.drv', No symbols loaded.
'Laby.exe': Unloaded 'C:\WINDOWS\system32\wdmaud.drv'
'Laby.exe': Loaded 'C:\WINDOWS\system32\wdmaud.drv', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\msacm32.drv', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\msacm32.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\midimap.dll', No symbols loaded.
'Laby.exe': Loaded 'C:\WINDOWS\system32\ksuser.dll', No symbols loaded.
First-chance exception at 0x0055ca40 in Laby.exe: 0xC0000094: Integer division by zero.
First-chance exception at 0x7c81eb33 in Laby.exe: Microsoft C++ exception: WindowsError @ 0x0012e97c.
'Laby.exe': Loaded 'C:\WINDOWS\system32\psapi.dll', No symbols loaded.
'Laby.exe': Unloaded 'C:\WINDOWS\system32\psapi.dll'
First-chance exception at 0x7c81eb33 in Laby.exe: Microsoft C++ exception: DefaultError @ 0x0012f068.
The thread 'Win32 Thread' (0x42c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xe94) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x244) has exited with code 0 (0x0).
First-chance exception at 0x004e1ef9 in Laby.exe: 0xC0000005: Access violation reading location 0xfeeefeee.
First-chance exception at 0x7c81eb33 in Laby.exe: Microsoft C++ exception: WindowsError @ 0x0012d9b8.
First-chance exception at 0x7c81eb33 in Laby.exe: Microsoft C++ exception: WindowsError @ 0x0012d9c8.
First-chance exception at 0x7c81eb33 in Laby.exe: Microsoft C++ exception: WindowsError @ 0x0012d9b8.
First-chance exception at 0x0055ca40 in Laby.exe: 0xC0000094: Integer division by zero.
First-chance exception at 0x7c81eb33 in Laby.exe: Microsoft C++ exception: WindowsError @ 0x0012e68c.
'Laby.exe': Loaded 'C:\WINDOWS\system32\psapi.dll', No symbols loaded.
'Laby.exe': Unloaded 'C:\WINDOWS\system32\psapi.dll'
First-chance exception at 0x7c81eb33 in Laby.exe: Microsoft C++ exception: DefaultError @ 0x0012ed78.
First-chance exception at 0x0055ca40 in Laby.exe: 0xC0000094: Integer division by zero.
First-chance exception at 0x7c81eb33 in Laby.exe: Microsoft C++ exception: WindowsError @ 0x0012e68c.
'Laby.exe': Loaded 'C:\WINDOWS\system32\psapi.dll', No symbols loaded.
'Laby.exe': Unloaded 'C:\WINDOWS\system32\psapi.dll'
First-chance exception at 0x7c81eb33 in Laby.exe: Microsoft C++ exception: DefaultError @ 0x0012ed78.
First-chance exception at 0x0055ca40 in Laby.exe: 0xC0000094: Integer division by zero.
First-chance exception at 0x7c81eb33 in Laby.exe: Microsoft C++ exception: WindowsError @ 0x0012e68c.
'Laby.exe': Loaded 'C:\WINDOWS\system32\psapi.dll', No symbols loaded.
'Laby.exe': Unloaded 'C:\WINDOWS\system32\psapi.dll'
First-chance exception at 0x7c81eb33 in Laby.exe: Microsoft C++ exception: DefaultError @ 0x0012ed78.

It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
Advertisement
Ok I have read that what happens in first error exception is it checks if the program handles the exception. If not, it does second chance exception and stops the program.
If the program does handle the exception, it continues.
What I did in my program is:
static void se_translator (unsigned int e, PEXCEPTION_POINTERS p){	WindowsError WinErr;	WinErr.Ptr = p;	throw WinErr;}ErrorHandle::ErrorHandle (){	this->bErrorHandle = TRUE;	this->bThrowingError = FALSE;	this->ErrorPosition = 0;	this->InitialScopeErrorPosition();	_set_se_translator (se_translator);


So it should have throwed WindowsError, and since I have a try catch in my main, it should have jumped to the catch WindowsError, but it doesnt.
Why it doesnt jump to there?
Also, is there a way to create first chance exceptions to test my exception mechanisem?


It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
Assuming you're using the MSVC compiler, did you use the /EHa switch? (Enable C++ Exceptions: Yes With SEH Exceptions)
----Erzengel des Lichtes光の大天使Archangel of LightEverything has a use. You must know that use, and when to properly use the effects.♀≈♂?
Quote:Original post by Erzengeldeslichtes
Assuming you're using the MSVC compiler, did you use the /EHa switch? (Enable C++ Exceptions: Yes With SEH Exceptions)


Yes, I have /EHa switch.
Enable C++ Exceptions is no.
What does this mean?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
If you have /EHa in the command line, but Enable C++ Exceptions: No in Code Generation, the Command Line will override the Code Generation window, so the compiler should still make asynchronous exceptions.

Beyond that, I can't help. Try putting __try/__except around the offending peice of code, just to see if it will catch it.

And do you have a catch(...), or just a catch(WindowsErr)?

Also, make sure you don't have the /GX switch active.
----Erzengel des Lichtes光の大天使Archangel of LightEverything has a use. You must know that use, and when to properly use the effects.♀≈♂?
I don't think you're supposed to throw C++ exceptions from a SEH filtering function - which is supposed to filter exceptions, not translate them. Additionally, the filter function is most likely to be working in whole another context than the normal program flow, with another stack (someone please correct me if I'm wrong), so the standard C++ unwinding won't work (at least it won't do anything good).

A quick test program:
#include <windows.h>#include <excpt.h>class A{public:   ~A(){      OutputDebugStr("~A()\n");   }};void genFault(void){   int *p = NULL;   *p = 17;};void body(void){   A tmp;   genFault();};int se_translator(unsigned int, PEXCEPTION_POINTERS){   throw "SomeCPPException()";   // use this instead!   // write the exception info to the log   // (including current call stack, for example)   //return EXCEPTION_CONTINUE_SEARCH;}void test(void){   __try   {      OutputDebugStr("__try\n");      body();   }   __except( se_translator(GetExceptionCode(), GetExceptionInformation()) )   {      OutputDebugStr("__except\n");   };};int main(){   try   {      OutputDebugStr("try\n");      test();   }   catch(...)   {      OutputDebugStr("catch(...)\n");   };};
Leads to infinite rethrowing of char*.

Using the commented version of the se_translator function works well.
Quote:Original post by deffer
I don't think you're supposed to throw C++ exceptions from a SEH filtering function - which is supposed to filter exceptions, not translate them. Additionally, the filter function is most likely to be working in whole another context than the normal program flow, with another stack (someone please correct me if I'm wrong), so the standard C++ unwinding won't work (at least it won't do anything good).

A quick test program:
*** Source Snippet Removed ***Leads to infinite rethrowing of char*.

Using the commented version of the se_translator function works well.


Actually throwing from the se_translator is something I read about in an article/tutorial at code guru or some place like that.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower.Quote:Original post by Toolmaker Quote:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
Quote:Original post by The C modest god
Actually throwing from the se_translator is something I read about in an article/tutorial at code guru or some place like that.


Care to share the source?

EDIT: I found it www.codeguru.com/Cpp/Cpp/cpp_mfc/article.php/c851.
Now I see... I though that _set_se_translator was your own function and that you were catching SEH exceptions in a standard way.
One of the main points of the SEH filtering functions is to basically translate a Win32 exception into a C++ exception. You do need to enable SEH exceptions in the project (and make sure you enable it in both debug and release and what ever other configurations you may have). I've done it before in code. It will work just fine. Just throw an exception from the filter function that your expecting to catch (or just use the catch all elipses in the catch statement).

try
{
}
catch(...)
{
}

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

Linky MSDN:Handling Exceptions, Part 17

"I can't believe I'm defending logic to a turing machine." - Kent Woolworth [Other Space]

This topic is closed to new replies.

Advertisement