[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference clt::cma

Title:DECthreads Conference
Moderator:PTHRED::MARYSTEON
Created:Mon May 14 1990
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1553
Total number of notes:9541

1535.0. "Exception handling in C++" by NNTPD::"bianchir@mail.dec.com" (Remy Bianchi) Wed Apr 30 1997 13:10

  Hello,

  I just 'received' a C++ program that uses DEC Threads. 

  The whole program is mixing standard exception handling try/catch with DEC
  Threads exception handling TRY/CATCH_ALL/ENDTRY.

  I personnaly don't like this mix of styles and tried to replace everything
  with C++ error handling.

  But finally it does not work, it seems that C++ error handling does not trap
  all the errors. For example my error handler for a thread does not catch

    Segmentation fault

  This kind of error is well catched with TRY/CATCH_ALL/ENDTRY.

  Is there any solution where I only use C++ exception handling ?

  Thanks in advance, 
    Regards, Remy Bianchi.
[Posted by WWW Notes gateway]
T.RTitleUserPersonal
Name
DateLines
1535.1DCETHD::BUTENHOFDave Butenhof, DECthreadsWed Apr 30 1997 14:3914
We've talked with the C++ folks about this before, and I recall some
suggestion that they were thinking about providing some way to trap "foreign"
exceptions using catch. But, currently, C++ catches only C++ exceptions.

However, although you can't "catch" the exceptions, all of your destructors
will run, which is usually what's really important.

Besides, while there's some value to making SIGSEGV run destructors (although
there's no guarantee everything will work), there's very little value to
catching a SIGSEGV. It usually signals some sort of serious problem (often a
nasty asynchronous data corruptor) that will probably prevent the process
from operating correctly anyway.

	/dave
1535.2catch and throwDECC::SEIGELThu May 01 1997 13:555
You can catch the SIGSEGV signal and throw a C++ exception
from your SIGSEGV signal handler.  The exception will then be properly
handled as a normal C++ exception.

Harold
1535.3Be careful about "changing" exceptions.WTFN::SCALESDespair is appropriate and inevitable.Mon May 05 1997 18:2913
.2> You can catch the SIGSEGV signal and throw a C++ exception
.2> from your SIGSEGV signal handler.  The exception will then be properly
.2> handled as a normal C++ exception.

Be aware, however, that if you do this, anything using the DECthreads TRY/CATCH
macros will not recognise the resulting exception as a SEGV, and this may result
in unexpected and counterintuitive behavior.  (E.g., if your handler is in an
RPC server, then a SEGV during an RPC call will not be reflected back to the
client side correctly...but, with such a potentially catastrophic failure as a
SEGV, you may not care... :-} )


				Webb