Received: from PACIFIC-CARRIER-ANNEX.MIT.EDU by po7.MIT.EDU (5.61/4.7) id AA13948; Fri, 15 Mar 96 17:50:16 EST
Received: from cygnus.com by MIT.EDU with SMTP
	id AA17134; Fri, 15 Mar 96 17:47:14 EST
Received: from tweedledumb.cygnus.com (tweedledumb.cygnus.com [192.80.44.1]) by cygnus.com (8.6.12/8.6.9) with SMTP id OAA13846; Fri, 15 Mar 1996 14:45:18 -0800
Received: from kr-laptop.cygnus.com by tweedledumb.cygnus.com (4.1/4.7) id AA16631; Fri, 15 Mar 96 17:43:54 EST
Received: (from raeburn@localhost) by kr-laptop.cygnus.com (8.6.12/8.6.12) id RAA18964; Fri, 15 Mar 1996 17:43:52 -0500
Sender: raeburn@cygnus.com
To: David Brownell <brownell@ix.netcom.com>
Cc: pthreads@MIT.EDU
Subject: Re: pthread_cancel() and c++ destructors
References: <199603132137.PAA23083@cascade.cs.utexas.edu>
	<3149DE5F.A21@ix.netcom.com>
From: Ken Raeburn <raeburn@cygnus.com>
Date: 15 Mar 1996 17:43:50 -0500
In-Reply-To: David Brownell's message of Fri, 15 Mar 1996 11:17:19 -1000
Message-Id: <tx14trq5655.fsf@kr-laptop.cygnus.com>
Organization: Cygnus Support, Cambridge MA
Lines: 31


   From: David Brownell <brownell@ix.netcom.com>
   Date: Fri, 15 Mar 1996 11:17:19 -1000


   The only implementation of MT/C++ that I _know_ has paid attention to
   integrating the two properly is on Solaris 2.5, and that's what it does.
   Last I checked (a year ago) nobody had done that for G++ and a pthreads
   implementation such as MIT's.  (But folk were quite open to modifying
   both appropriately.)

It would be nice if the g++ exception mechanism were thread-safe.  I
complained to mrs about this, oh, probably at least 6 months ago.  It
uses global variables.  It would also be nice if it worked on all
systems, with optimization.  Far as I'm concerned, the g++ eh code
just doesn't work until these are fixed.

   The options are basically to use the existing C++ stack unwind-protect
   mechanism, or invent a new one like POSIX did in its C binding (POSIX.1c  
   defined pthread_cleanup_push/pop).

   That's an easy choice for a developer, since the latter means that the
   built-in C++ mechanism can't _ever_ be used.

Why not?  It may not be portable to rely on, but I think any vendor
shipping quality implementations of pthreads and C++ will make sure
they play nice together.  Just put the EH hooks into the C compiler,
build pthread_cleanup_* on top, and make pthread_cancel raise a magic
exception in the context of the cancelled thread.

Ken
