From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21202 invoked by alias); 7 Jan 2008 15:12:06 -0000 Received: (qmail 21192 invoked by uid 22791); 7 Jan 2008 15:12:05 -0000 X-Spam-Check-By: sourceware.org Received: from amber.ccs.neu.edu (HELO amber.ccs.neu.edu) (129.10.116.51) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 07 Jan 2008 15:11:42 +0000 Received: from c-67-166-126-219.hsd1.ut.comcast.net ([67.166.126.219] helo=welcome.tohell) by amber.ccs.neu.edu with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.50) id 1JBtdc-0006eG-5C for pthreads-win32@sourceware.org; Mon, 07 Jan 2008 10:11:40 -0500 Message-ID: <47824161.7000506@ccs.neu.edu> Date: Mon, 07 Jan 2008 15:12:00 -0000 From: Jon Rafkind User-Agent: Thunderbird 2.0.0.9 (X11/20071121) MIME-Version: 1.0 To: pthreads-win32@sourceware.org Subject: pthreads and exceptions Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2008/txt/msg00000.txt.bz2 Hi, I am experiencing an issue with pthreads 2.8.0 and c++ exceptions. If main spawns thread A and thread A spawns thread B then thread A throws an exception and tries to catch it, thread B will actually catch it. I have tried libpthreadGC2.dll and libpthreadGCE2.dll but the behavior is the same. Is there a way to make right the stack unwinding behavior match that as on Linux? Here is an example program which shows the behavior: #include #include #include using namespace std; class Fex: public exception{ public: Fex():exception(){} }; void * d1_child( void * x ){ try{ int i; printf( "d1 child running\n" ); for ( i = 0; i < 200000000; i++ ){ } } catch ( const Fex & f ){ printf( "d1 child fex\n" ); } printf( "d1 child done\n" ); } void * d1( void * x ){ try{ pthread_t child; pthread_create( &child, NULL, d1_child, NULL ); int i; for ( i = 0; i < 100000000; i++ ){ } printf( "d1 throwing fex\n" ); throw Fex(); pthread_join( child, NULL ); printf( "d1 joined child\n" ); } catch ( const Fex & f ){ printf( "d1 fex\n" ); } printf( "d1 done\n" ); return NULL; } void * d2( void * x ){ try{ throw Fex(); } catch ( const Fex & f ){ printf( "d2 fex\n" ); } return NULL; } int main(){ pthread_t n1, n2; pthread_create( &n1, NULL, d1, NULL ); pthread_create( &n2, NULL, d2, NULL ); pthread_join( n1, NULL ); pthread_join( n2, NULL ); } This will print d2 fex d1 child running d1 throwing fex d1 child fex d1 child done thanks, jon