Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: segmentation fault exception handling

Reply
Thread Tools

Re: segmentation fault exception handling

 
 
Ivan Vecerina
Guest
Posts: n/a
 
      06-29-2003
"Vasileios Zografos" <(E-Mail Removed)> wrote in message
news:bdnakv$qbr$(E-Mail Removed)...
> Hi, I have the following piece of code which sometimes throws a
> segmentation fault, because this.x, this.y, this.z might be unallocated
> (and it is not possible to initialize them). Its more of a geometric
> problem than programming fault.


Seg-faults during access to data members usually indicates that
the whole object itself has not been allocated adequately.

Does the 'this' pointer happen to be NULL when the segfault occurs?
Maybe what you want to do is a check such as:
if( this==0 ) .... // handle error condition...

It works in practice on some platforms, but is a bad idea in
any case, as this formally leads to undefined behavior.

As others mentioned, it *is* a programming fault to call
an object that hasn't been allocated and constructed.
The design of your code needs to be changed to avoid
such situations.

Feel free to provide more details if you want further guidance.

hth,
--
Ivan Vecerina, Dr. med. <> http://www.post1.com/~ivec
Soft Dev Manger, XiTact <> http://www.xitact.com
Brainbench MVP for C++ <> http://www.brainbench.com


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
like to know why it is segmentation fault on simple throw-exception program eric C++ 9 06-02-2011 06:20 PM
Segmentation fault at raise exception. O01eg Oleg Ruby 6 04-24-2010 06:33 PM
signal handling and (structured) exception handling Peter C++ 34 10-17-2009 10:03 AM
SoapExtension for Global Exception handling; but prevent exception from propagating!! VSK ASP .Net Web Services 0 07-29-2003 05:39 PM
Re: segmentation fault exception handling Vasileios Zografos C++ 5 07-01-2003 02:10 PM



Advertisments