Solved

First Chance Exception message in vc++

Posted on 2006-10-31
11
662 Views
Last Modified: 2009-12-16
why do i get the following error while running a database application:

First-chance exception in CaliberationDB.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.
0
Comment
Question by:adders99
  • 4
  • 2
  • 2
11 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 168 total points
Comment Utility
First-chance exception messages can be ignored. They are printed when some exception was thrown and catched by exception handler. This can happen both in your own code or in some libraries which are called from your code. The problem is unhandled exception, which is thrown and not catched anywhere - such exception terminates application. Catched (First Chance) exception is OK.
0
 
LVL 86

Assisted Solution

by:jkr
jkr earned 166 total points
Comment Utility
To elaborate a bit more:

A "First-Chance-Exception" is nothing to worry about. 'First-chance exception in xxx...' just means that a function from within the 'xxx' caused an exception exception that was handled successfully inside the SEH frame that was active when the exception occurred. You can think of it being the same as if you use code like this:

long l;

__try // set up current SEH frame
{
CopyMemory ( &l, 0, sizeof ( long)); // read from 0x00000000
}
__except( EXCEPTION_EXECUTE_HANDLER) // handler for current frame
{
puts ( "We knew that this would go wrong...");
}

(Additional info: MS KB Article Q105675)

The article can be found at http://support.microsoft.com/support/kb/articles/q105/6/75.asp

A first chance exception is called so as it is passed to a debugger before the application 'sees' it. This is done by sending a 'EXCEPTION_DEBUG_EVENT' to the debugger, which can now decide whether it is passed to the apllication to handle it or 'ignore' it (e.g. like an 'EXCEPTION_BREAKPOINT' aka 'int 3'). If the exception isn't handled, it becomes a '2nd chance' exception, the debugger 'sees' it the 2nd time and will usually terminate the program (without using a debugger, these exceptions end up at 'UnhandledExceptionFilter()' which will also signal the exception to the user with one of these 'nice' message boxes and terminate the program, also...)

In short: This message is only generated by a debugger & you can safely ignore it...
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
Comment Utility
To add to above information:

The first chance exception is not shown when using C++ exceptions.

jkr, do you know whether these messages were suppressed by the debugger or is C++ exception based on somewhat different than SEH ?

Regards, Alex
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
Firts chance exceptions are shown when using C++ exceptions.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 39

Assisted Solution

by:itsmeandnobodyelse
itsmeandnobodyelse earned 166 total points
Comment Utility
>>>> Firts chance exceptions are shown when using C++ exceptions.

Didn't get an output when I run that sequence with VC8:

bool invalid(vector<int>::iterator& it)
{
      try
      {
        int l;
        memcpy(&l, 0, 4);
            if (it == Buffer::invalid.end())
                  return true;
      }
      catch (...)
      {
      }
      return false;
}

In multiple projects of VC6 and VC8 I experienced 'first chance exceptions' only for code of foreign libraries like active-x controls or MFC dll .

Regards, Alex
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
I see firts-time exception running this under VC++ 8.0 debugger:

#include "stdafx.h"
#include <stdexcept>

int _tmain(int argc, _TCHAR* argv[])
{
    try
    {
        throw std::runtime_error("Test");
    }
    catch (const std::exception&)
    {
          
    }

    return 0;
}
0
 
LVL 48

Expert Comment

by:AlexFM
Comment Utility
One day I should learn to write "first" and not "firts" :(
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
>>jkr, do you know whether these messages were suppressed by the debugger or is C++ exception based on
>>somewhat different than SEH ?

These are completely different mechanisms/concepts. You can translate C++ exceptions to SEH exceptions using '_set_se_translator()', though. SEH on Win32 is way closer to the system level than C++ exceptions - remeber that Win32 also supports other languages ;o)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now