473,405 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

whats "First-chance exception", how do i fix it?

Hi all,

I'm writing an app in vc++ 2k5 (all native/unmanaged). This application does
a lot of multithreading and socket programming. Its been months since I'm
developing this application, at this point a lot of it is working just fine,
my app running fine, threads r being made and destroyed, memory is being
dynamically allocated at God knows how many places and ,hopefully, getting
deallocated as well. Its just by coincedence I happened to look at my output
window when my application is running in the debugger, and I see the
following line printed thousands and thousands of times (each line has
different addresses):

First-chance exception at 0x7c4f5dc2 in myapp.exe: 0xC0000005: Access
violation reading location 0x3233342e.

As I said everything is working fine, app is not crashing anywhere. Windows
Task Manager is not showing any *significant* memory leaks. Why is this line
being printed, I mean where should I look for the possible bugs, what are
the typical things that a c++ programmer mistakenly does that causes this
exception? Just by reading it I 'm sure something really wrong is happening
and it just so happens that its not crashing my app, but I dont wanna ignore
it and want to fix it.

Regards,

-ab.

Sep 13 '06 #1
2 24479
Its just by coincedence I happened to look at my output
window when my application is running in the debugger, and I see the
following line printed thousands and thousands of times (each line has
different addresses):

First-chance exception at 0x7c4f5dc2 in myapp.exe: 0xC0000005: Access
violation reading location 0x3233342e.

As I said everything is working fine, app is not crashing anywhere. Windows
Task Manager is not showing any *significant* memory leaks. Why is this line
being printed, I mean where should I look for the possible bugs, what are
the typical things that a c++ programmer mistakenly does that causes this
exception?
The message means that an exception is raised somewhere (at the specified
address). Since the application does not terminate with a second-chance exception,
it also means that the exception is handled somewhere.

Since the number of exceptions is big, it is possible that there is a problem
with the application (though not necessarily - may be this exception is expected
and handled). You can check what is going on if you ask the debugger
to break on first chance exceptions. For this, open Exceptions dialog, find
the exception mentioned in the debug output (in this case it is "access violation"
exception, should be under Win32 exceptions node), and select checkbox called
"Thrown" for the given exception.

Next time the debugger should break immediately at the moment when
the exception is raised. You should usually check two things:
- Why is this exception raised (see the call stack and parameters of the functions
on the call stack - you might need good symbols for system dlls to do this,
see VS debugger documentation on how to download symbols from the symbol server)
- Who could handle this exception (see the call stack for functions with
exception handlers)

This should usually tell you if the exception is dangereous or not,
and what could be done to get rid of it if needed.

Oleg
http://www.debuginfo.com/

Sep 13 '06 #2
Hey Thanks so much. I just tried this and found the bug so easily. Its a
network related functionality in my code that was causing this problem.

I think this exception should be enabled by default when we install the
vc2k5 so that developers know about this kind of functionality problem early
in their development.

Regards,

-ab.

"Oleg Starodumov" <com-dot-debuginfo-at-olegwrote in message
news:Oq**************@TK2MSFTNGP03.phx.gbl...
>
Its just by coincedence I happened to look at my output
window when my application is running in the debugger, and I see the
following line printed thousands and thousands of times (each line has
different addresses):

First-chance exception at 0x7c4f5dc2 in myapp.exe: 0xC0000005: Access
violation reading location 0x3233342e.

As I said everything is working fine, app is not crashing anywhere.
Windows
Task Manager is not showing any *significant* memory leaks. Why is this
line
being printed, I mean where should I look for the possible bugs, what
are
the typical things that a c++ programmer mistakenly does that causes
this
exception?

The message means that an exception is raised somewhere (at the specified
address). Since the application does not terminate with a second-chance
exception,
it also means that the exception is handled somewhere.

Since the number of exceptions is big, it is possible that there is a
problem
with the application (though not necessarily - may be this exception is
expected
and handled). You can check what is going on if you ask the debugger
to break on first chance exceptions. For this, open Exceptions dialog,
find
the exception mentioned in the debug output (in this case it is "access
violation"
exception, should be under Win32 exceptions node), and select checkbox
called
"Thrown" for the given exception.

Next time the debugger should break immediately at the moment when
the exception is raised. You should usually check two things:
- Why is this exception raised (see the call stack and parameters of the
functions
on the call stack - you might need good symbols for system dlls to do
this,
see VS debugger documentation on how to download symbols from the symbol
server)
- Who could handle this exception (see the call stack for functions with
exception handlers)

This should usually tell you if the exception is dangereous or not,
and what could be done to get rid of it if needed.

Oleg
http://www.debuginfo.com/



Sep 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
by: James Curran | last post by:
I'd like to make the following proposal for a new feature for the C# language. I have no connection with the C# team at Microsoft. I'm posting it here to gather input to refine it, in an "open...
5
by: comp.lang.php | last post by:
$orderBy = 's.app_date desc, s.last_name asc, s.first_name asc, s.mi asc'; if ($_REQUEST) { $ascArray = array('asc' => 'desc', 'desc' => 'asc'); // ARRAY OF ALL ORDERING POSSIBILITIES $junk =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.