Solved

First Chance Exception message in vc++

Posted on 2006-10-31
11
663 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
ID: 17847937
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
ID: 17850646
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
ID: 17856615
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 48

Expert Comment

by:AlexFM
ID: 17856639
Firts chance exceptions are shown when using C++ exceptions.
0
 
LVL 39

Assisted Solution

by:itsmeandnobodyelse
itsmeandnobodyelse earned 166 total points
ID: 17857269
>>>> 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
ID: 17857360
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
ID: 17857366
One day I should learn to write "first" and not "firts" :(
0
 
LVL 86

Expert Comment

by:jkr
ID: 17859793
>>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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

825 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