Mailinglist Archive: opensuse-programming (148 mails)

< Previous Next >
Re: [suse-programming-e] OS C++ Exception interoperation?
  • From: "Steven T. Hatton" <hattons@xxxxxxxxxxxxxxxxxx>
  • Date: Sat, 11 Sep 2004 20:46:47 -0400
  • Message-id: <200409112046.47304.hattons@xxxxxxxxxxxxxxxxxx>
On Friday 10 September 2004 20:46, Jerry Feldman wrote:
> On Fri, 10 Sep 2004 19:11:52 -0400
>
> "Steven T. Hatton" <hattons@xxxxxxxxxxxxxxxxxx> wrote:
> > Is there a similar facility in Linux for exception "exception
> > registration"?
> > http://www.codeproject.org/cpp/exceptionhandler.asp#xx515459xx
> >
> > For this discussion, I will consider exceptions to be those that are
> > explicitly thrown or occur due to conditions like divide by zero or
> > null pointer access.
>
> While I'm not 100% familiar with the internals of exception handling in
> C++ and Java on Linux, asynchronous behavior is delivered to processes
> by the signal mechanism. The process sets up a signal handler, and upon
> the receipt of that signal, the OS then delivers it to the process. The
> try-catch mechanism is a language specific mechanism. The language, in
> this case C++, generates the appropriate code for the target OS and
> processor. Stack management and unwinding is generally performed by the
> language.

I really didn't think very hard about the topic before I posted. I
immediately realized it was potentially important, and wanted to call it to
the attention of others. You are correct in bringing up signals. My
understanding is, the way traditional Java deals with null pointer access is
by checking all access for you. It (the JVM) /is/ the OS. I wonder how the
GNU Java compiler deals with exception handling?

I really don't know how Unix signals affect the execution of my C++ programs -
other than the fact they crash when receiving SIGSEGV. I guess the signal
handling is part of the gcc implementation. So the mechanism for "exception
registration" would need to be part of the compiler implementation. It would
be nice to have such functionality defined in a platform-independent way.

In order for something like this to work, the signal would have to cause an
exception to be thrown to the errant function, or at least from that
function. I think I might post this to the GCC mailing list.
--
Regards,
Steven

< Previous Next >
Follow Ups