Date: Fri, 19 Nov 1999 16:31:06 -0700 (MST) From: "Russell L. Carter" <rcarter@pinyon.org> To: freebsd-current@freebsd.org Cc: rcarter@vip.consys.com Subject: threads, exceptions, and current Message-ID: <199911192331.QAA63190@vip.consys.com>
next in thread | raw e-mail | index | archive | help
Hi, I'm trying to track down a problem with threads, C++ exceptions and ACE on -current. Is the appended little program supposed to work? If not, why not? It SIGABRTs immediately after the last throw with egcs-2.95.2, and also with a month old or so egcs-2.91.66, stock cc. Also with LinuxThreads, so it's not libc_r specific. I am told but cannot verify at the minute that this works on other platforms. Thanks, Russell $ c++ -pthread -D_THREAD_SAFE ex_test.cpp $ ./a.out Throwing Ex: Caught Ex, now rethrowing it... Caught Ex thrown from main thread. Throwing Ex: Caught Ex, now rethrowing it... Abort trap (core dumped) $ ex_test.cpp: #include <stdio.h> #include <pthread.h> class Ex {}; class testEx { public: void throwEx () { fprintf(stderr, "Throwing Ex:\n"); throw Ex (); } }; void * f(void *) { testEx thetest; thetest.throwEx (); } void * g(void *arg) { try { f(arg); } catch (Ex &ex) { fprintf(stderr, "Caught Ex, now rethrowing it...\n"); throw; } } int main (void) { int *arg = 0; try { g((void *) arg); } catch (Ex &ex) { fprintf(stderr, "Caught Ex thrown from main thread.\n"); } pthread_t ex_thread; pthread_attr_t *attr = 0; try { pthread_create(&ex_thread, attr, g, (void *) arg); } catch (Ex &ex) { fprintf(stderr, "Caught Ex thrown from child thread.\n"); } pthread_join(ex_thread, (void **) &arg); return 0; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199911192331.QAA63190>