How to immediately terminate program in C++

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 10
Reputation: 35nando is an unknown quantity at this point 
Solved Threads: 0
35nando 35nando is offline Offline
Newbie Poster

How to immediately terminate program in C++

 
0
  #1
May 17th, 2009
Hello!

When my program in C++ exits, it throws errors like:
EInvalidPinter with message 'Invalid Pointer operation' ...
and later:
EAccessViolation with mesage 'Access violation at address 00000010 ...
and finally:

Abonarmal Program Termination


I can't locate the code responsible for it ( I am using many libraries in my program). I think that it's coused by some destructor (or uncalled destructor).
It appers only when I exit the program, and does not affect program work.

Is there a way to immediately terminate the program (without errors), so the memory would have to be freed by operating system?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,442
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1474
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: How to immediately terminate program in C++

 
0
  #2
May 17th, 2009
You really need to fix the problem instead of trying to hid it.Try commenting out large blocks of code until the program no longer produces those errors. That will narrow down your search for the problem.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: How to immediately terminate program in C++

 
0
  #3
May 17th, 2009
Are you sure that the best method to avoid a threat is to cry: "Keep out of my sight!"?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 630
Reputation: daviddoria is a jewel in the rough daviddoria is a jewel in the rough daviddoria is a jewel in the rough 
Solved Threads: 46
daviddoria daviddoria is offline Offline
Practically a Master Poster

Re: How to immediately terminate program in C++

 
0
  #4
May 17th, 2009
If the problem is indeed in a library and you not doing anything incorrectly, maybe try exit(0) (from stdlib) as the last line of the program? I don't know if that would help? It would be nice if you could kind of find where it happens though so you could report the problem to the mailing list/forum for that library.

Dave
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: How to immediately terminate program in C++

 
0
  #5
May 18th, 2009
> It appers only when I exit the program, and does not affect program work.
You mean it doesn't affect it YET.

Memory corruption problems move around the code over time (as you continue to make changes to the code).

All of a sudden, you could find it happens at some much more obvious and inconvenient point in the code (say save file).

If your regular debugger isn't providing much help, then try WinDbg
http://www.microsoft.com/whdc/devtoo...g/default.mspx
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 793
Reputation: siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of siddhant3s has much to be proud of 
Solved Threads: 135
siddhant3s's Avatar
siddhant3s siddhant3s is offline Offline
Master Poster

Re: How to immediately terminate program in C++

 
0
  #6
May 18th, 2009
>>All of a sudden, you could find it happens at some much more obvious and
>>inconvenient point in the code (say save file).
Murphy's Law for Computer programming: A program with undefined behavior(or ill defined behavior) will continue to work in all debugging session and will halt when a extremely important transaction is going on (for example a billion dollar deal).
LoL, so true
Siddhant Sanyam
(Not posting much)
Migrate to Standard C++ :When to tell your C++ Code is Non-Standard.
Please Read before posting: How To Ask Questions The Smart Way
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 22
Reputation: neigyl_noval is an unknown quantity at this point 
Solved Threads: 5
neigyl_noval neigyl_noval is offline Offline
Newbie Poster

Re: How to immediately terminate program in C++

 
0
  #7
May 18th, 2009
35nando:
When my program in C++ exits, it throws errors like:
EInvalidPinter with message 'Invalid Pointer operation' ...
and later:
EAccessViolation with mesage 'Access violation at address 00000010 ...
and finally:

Abonarmal Program Termination
If your program uses alloc() or the like or
whatever that allocates something to a pointer, and
doesn't use free() or the like, it results to "invalid pointer operation" and "violation at address 00000010".

Allocate to a pointer and deallocate it if unused.

If this is not the case, recheck your constructors with its destructors.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC