From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f678f,7174009ad4aae9ec,start X-Google-Attributes: gidf678f,public X-Google-ArrivalTime: 1994-10-31 21:57:09 PST Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!EU.net!uunet!psinntp!hk.super.net!wanchai.hk.super.net!hk.super.net!not-for-mail From: lijewski@HK.Super.NET (Mr Mike James Lijewski) Newsgroups: comp.unix.osf.misc Subject: bug with DEC C++ exceptions and Pthreads Date: 1 Nov 1994 12:02:06 +0800 Organization: Hong Kong SuperNet Message-ID: <394eju$4ji@hk.super.net> NNTP-Posting-Host: hk.hk.super.net Summary: C++ bug Keywords: C++ DEC OSF Pthreads exceptions Script started on Mon Oct 31 08:43:20 1994 % uname -a OSF1 bsr02 V3.0 358 alpha % cat a.C // // This program illustrates that the C++ exception handling function // terminate() is maintained on a per-process basis not a per-thread // basis. This appears to contradict the intent of the Annotated C++ // Reference Manual. In particular, in the commentary in section 15.6c // where both terminate() and unexpected() are talked about, we have the // following statement: // // Note that these functions must be specific to individual threads in a // multi-threaded program. // // Compile as: // // cxx a.C -lpthreads -lc_r -lmach // #include #include #include #ifdef __DECCXX #include #endif class X {}; static void main_terminate_handler () { (void) printf("exiting via terminate_handler() set in main() ...\n"); exit(1); } static void thread_terminate_handler () { (void) printf("exiting via terminate_handler() set in thread ...\n"); exit(1); } static void* work (pthread_addr_t ignore) { (void) printf("Setting terminate() in a thread ...\n"); set_terminate(thread_terminate_handler); sleep(3); (void) printf("Exiting the thread ...\n"); return 0; } main () { (void) printf("Setting terminate() in main() ...\n"); set_terminate(main_terminate_handler); pthread_t thread; pthread_addr_t status; if (pthread_create(&thread, pthread_attr_default, work, 0) < 0) perror("pthread_create"), exit(1); sleep(1); (void) printf("throwing an exception in main() ...\n"); throw X(); (void) printf("Exiting main() ...\n"); return 0; } % cxx a.C -lpthreads -lc_r -lmach % ./a.out Setting terminate() in main() ... Setting terminate() in a thread ... throwing an exception in main() ... exiting via terminate_handler() set in thread ... script done on Mon Oct 31 08:43:57 1994