Click here to Skip to main content
15,887,267 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WinSock 2 + UNICODE / Win32 Pin
Stephen Hewitt19-Apr-10 14:41
Stephen Hewitt19-Apr-10 14:41 
GeneralRe: WinSock 2 + UNICODE / Win32 Pin
Fareed Rizkalla19-Apr-10 15:45
Fareed Rizkalla19-Apr-10 15:45 
Question[SOLVED]Problem using dmColor member of DEVMODE struct [modified] Pin
hhh19-Apr-10 7:14
hhh19-Apr-10 7:14 
QuestionUnhandled exception Pin
PankajB19-Apr-10 5:59
PankajB19-Apr-10 5:59 
AnswerRe: Unhandled exception Pin
Richard MacCutchan19-Apr-10 6:14
mveRichard MacCutchan19-Apr-10 6:14 
GeneralRe: Unhandled exception Pin
PankajB19-Apr-10 6:50
PankajB19-Apr-10 6:50 
GeneralRe: Unhandled exception Pin
Richard MacCutchan19-Apr-10 6:57
mveRichard MacCutchan19-Apr-10 6:57 
AnswerRe: Unhandled exception Pin
Stephen Hewitt19-Apr-10 14:09
Stephen Hewitt19-Apr-10 14:09 
In general the best thing to do with an access violation in some DLL you don't have source code for is to crash. It's amateurish to think that catching it solves any problems. If you think about it, it's self evident:

  1. Something went wrong.
  2. The unexpected event happened part way though a sequence of steps that probably should have been atomic.

I'll give some specific examples of the kind of problems that could occur:

  1. You were adding a node to a double-linked list when the access violation occurred. Now you have a node that is only partially linked in. Instead of crashing at the point of insertion you crash down the track when iterating over the list.
  2. The access violation happens after a call to EnterCriticalSection but before the corresponding LeaveCriticalSection. Instead of crashing at the problem location an entirely different thread now locks up.
  3. The crash was the last of a series of memory accesses of which some of the earlier ones (that didn't cause a crash) corrupted the heap. You'll now crash at some later time when allocating or freeing memory.


You could come up with a million of these examples. In most cases "recovering" from low-level exceptions by catching them turns a bad problem into a worse one. Sometimes crashing is a feature; don't make things worse trying to "fix" things.

You may already know all this (you did mention something about terminating correctly), but I thought it best to point out just in case. There's also the fact that moving the manifestation of a problem (a crash) even slightly from the source of the problem makes it many times harder to fix in future.
Steve

GeneralRe: Unhandled exception Pin
ramana.g19-Apr-10 19:30
ramana.g19-Apr-10 19:30 
GeneralRe: Unhandled exception Pin
Stephen Hewitt19-Apr-10 21:48
Stephen Hewitt19-Apr-10 21:48 
GeneralRe: Unhandled exception Pin
Saurabh.Garg19-Apr-10 19:51
Saurabh.Garg19-Apr-10 19:51 
GeneralRe: Unhandled exception Pin
Stephen Hewitt19-Apr-10 21:48
Stephen Hewitt19-Apr-10 21:48 
Questiontransaction - rollback in C ??? Pin
aa_zz19-Apr-10 0:20
aa_zz19-Apr-10 0:20 
AnswerRe: transaction - rollback in C ??? PinPopular
CPallini19-Apr-10 0:39
mveCPallini19-Apr-10 0:39 
AnswerRe: transaction - rollback in C ??? PinPopular
KarstenK19-Apr-10 1:09
mveKarstenK19-Apr-10 1:09 
GeneralRe: transaction - rollback in C ??? Pin
aa_zz19-Apr-10 22:29
aa_zz19-Apr-10 22:29 
GeneralRe: transaction - rollback in C ??? Pin
CPallini19-Apr-10 22:38
mveCPallini19-Apr-10 22:38 
GeneralRe: transaction - rollback in C ??? Pin
aa_zz19-Apr-10 22:45
aa_zz19-Apr-10 22:45 
GeneralRe: transaction - rollback in C ??? Pin
CPallini19-Apr-10 22:52
mveCPallini19-Apr-10 22:52 
GeneralRe: transaction - rollback in C ??? Pin
KarstenK19-Apr-10 22:42
mveKarstenK19-Apr-10 22:42 
GeneralRe: transaction - rollback in C ??? Pin
aa_zz20-Apr-10 21:22
aa_zz20-Apr-10 21:22 
GeneralRe: transaction - rollback in C ??? Pin
KarstenK20-Apr-10 21:35
mveKarstenK20-Apr-10 21:35 
QuestionBlack Berry not working with AT commands to Send SMS. Pin
Le@rner19-Apr-10 0:08
Le@rner19-Apr-10 0:08 
AnswerRe: Black Berry not working with AT commands to Send SMS. Pin
Code-o-mat19-Apr-10 6:21
Code-o-mat19-Apr-10 6:21 
QuestionSDI Data Transfer (Windows Explorer) Pin
hellogany18-Apr-10 23:04
hellogany18-Apr-10 23:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.