This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
MT save exception handling
- To: egcs at cygnus dot com
- Subject: MT save exception handling
- From: Andreas Wimmer <wim at pdib84 dot joanneum dot ac dot at>
- Date: Thu, 4 Jun 1998 16:59:01 +0200
- Reply-To: wim at pdib84 dot joanneum dot ac dot at
>From what I have read so far in this mailing list, egcs is supposed to support
exception handling in multithreaded applications on my system (linux 2.0.33,
glibc 2.06, binutils 2.9.1.0.4, egcs 1.03a)
egcs has been configured with:
"--prefix=/usr/local/egcs --enable-threads --enable-shared --enable-haifa"
but the following simple example failed to run constantly without error
(I get segmentation faults or aborts every 2nd run or so )
---------------------------------------------------
#include <stdlib.h>
#include <iostream.h>
#include <iomanip.h>
#include <pthread.h>
int max_iter = 5000;
int g_nExCount1 = 0;
int g_nExMainCount = 0;
class SomeEx {};
void *
TestExceptionThread1 ( void * param )
{
for ( int n = 0; n < max_iter; n++ )
{
try
{
throw SomeEx();
}
catch( SomeEx & oError )
{
g_nExCount1++;
}
}
return NULL;
}
int
main(int argc, char ** argv)
{
cerr << " testing exception handling in multithreaded apps" << endl;
if (argc == 2)
{
max_iter = atoi(argv[1]);
}
cerr << "doing " << max_iter << " iterations" << endl;
pthread_attr_t ptaThreadAttr1;
pthread_t ptThreadID1;
pthread_attr_init ( &ptaThreadAttr1 );
pthread_attr_setdetachstate ( &ptaThreadAttr1, PTHREAD_CREATE_JOINABLE );
pthread_create ( &ptThreadID1, &ptaThreadAttr1, TestExceptionThread1, NULL );
for ( int n = 0; n < max_iter; n++ )
{
try
{
throw SomeEx();
}
catch( SomeEx & oError )
{
g_nExMainCount++;
}
}
pthread_join ( ptThreadID1, NULL );
cerr << "exception count in thread1 " << g_nExCount1 << endl;
cerr << "exception count in main thread " << g_nExMainCount << endl;
return 0;
}
-------------------------------------------------------------
Can somebody tell me if this is a compiler bug or I have made a stupid error?!!