🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.codewarrior
Article #1127

Re: throw-ing exceptions at interrupt time?

#1127
From: meeroh
Date: Thu, 18 Oct 2001 03:05
65 lines
3095 bytes
In article <b53899e6.0110171315.5036e57c@posting.google.com>,
 elgoog@strangelight.com (Jason Lamport) wrote:

>I'm crossposting this to codewarrior.mac, since there seem to be more
>people on that list who could give definitive answers (i.e. Metroworks
>tech support people). That's why I'm including the original post at
>the bottom -- apologies for the extra bandwidth.

It is safe to throw an exception at interrupt time if:
a. the exception is caught in the interrupt handler as well
b. the class of the exception does not do anything unsafe in its 
constructors or any of its member functions you might call in the catch 
statement
c. you properly setup the exception subsystem by setting __initialize as 
the entry point of your application, shared library, or code resource 
(also remember to use __terminate for termination point of applications 
and shared libraries, and main for main entry point of applications). 

(Note that the default setup for app projects is to use __start instead 
of main, and that's okay for this purpose, but has other problems, which 
is why I recommend against it.)

For example:

InterruptHandler ()
{
   try {
      throw -1;
   } catch (std::exception& e) {
   }

   // bad, int not caught, exception leaves interrupt handler
}

InterruptHandler ()
{
   try {
      throw std::exception ("oops");
   } catch (...) {
   }

   // bad, std::exception constructor copies the string -- not interrupt 
safe
}

InterruptHandler ()
{
   try {
      throw MyException (-1);
   } catch (MyException& e) {
      e.InterruptUnsafeFunction ();
   }
   
   // bad, catch statement not interrupt safe
}

You get the idea. The exception handling subsystem itself is interrupt 
safe. If the exception classes and interrupt safe and you keep your 
exceptions to yourself, you are ok.

hth

meeroh
-- 
To get random signatures put text files into a folder called "Random Signatures" into your Preferences folder.
Technical Details
Message-ID: <macdev-C9FBE7.23055917102001@senator-bedfellow.mit.edu>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsswitch.lcs.mit.edu!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!dreaderd!not-for-mail
References: <b53899e6.0110152106.7d06e0fb@posting.google.com> <8CA031356232A730.29E614E5B9E85DCC.837A0ADCBC1AE7F6@lp.airnews.net> <b53899e6.0110171315.5036e57c@posting.google.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10bcce,d3234953ce62cee2
X-Google-Attributes: gid10bcce,public
X-Google-Thread: f635e,54ce753f0fa01891
X-Google-Attributes: gidf635e,public
X-Google-ArrivalTime: 2001-10-17 20:05:59 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsswitch.lcs.mit.edu!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!dreaderd!not-for-mail
From: meeroh <macdev@meeroh.org>
Newsgroups: comp.sys.mac.programmer.codewarrior,codewarrior.mac
Mail-Copies-To: poster
Subject: Re: throw-ing exceptions at interrupt time?
Organization: MIT
References: <b53899e6.0110152106.7d06e0fb@posting.google.com> <8CA031356232A730.29E614E5B9E85DCC.837A0ADCBC1AE7F6@lp.airnews.net> <b53899e6.0110171315.5036e57c@posting.google.com>
User-Agent: MT-NewsWatcher/3.1 (PPC)
Date: Wed, 17 Oct 2001 23:05:59 -0400
Message-ID: <macdev-C9FBE7.23055917102001@senator-bedfellow.mit.edu>
Lines: 65
NNTP-Posting-Host: NEON-20.MIT.EDU
X-Trace: 1003374359 senator-bedfellow.mit.edu 1910 18.101.0.201