Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Sat, 29 Jun 2002 18:09:09 -0400 Subject: C++ Exceptions in Multithreaded Applications Crash Content-Type: multipart/mixed; boundary=Apple-Mail-1--163290563 Mime-Version: 1.0 (Apple Message framework v482) Cc: khan AT nanotech DOT wisc DOT edu To: cygwin AT cygwin DOT com From: Lenny Primak Message-Id: --Apple-Mail-1--163290563 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed This has been submitted to GCC GNATS as PR/7168. Using the G++ exception system from multiple threads corrupts the gcc's internal exception stack, due to not including the thread-specific exception context in the compile. GCC Version: 2.95.3-5 from default Cygwin install. I tried to re-compile gcc with --enable-threads=posix and with --enable-sjlj-exceptions with no results. The following program is used to determine if the exception context is thread-specific or not: --Apple-Mail-1--163290563 Content-Disposition: attachment; filename=gcc_exception.C Content-Transfer-Encoding: 7bit Content-Type: text/plain; x-unix-mode=0644; name="gcc_exception.C" #include #include #include extern "C" void * __get_eh_context (); static void* saved_eh_context = 0; static void* func(void*) throw(char*) { void* eh_cntxt = __get_eh_context(); printf("func() - eh_context = %X\n", eh_cntxt); if(saved_eh_context == 0) { saved_eh_context = eh_cntxt; } else { if(eh_cntxt == saved_eh_context) { printf("FATAL: Identical Exception Stacks!\n"); } else { printf("Great! Exception Stacks Differ.\n"); } } int svar = 5; try { throw 1; } catch(char*) { printf("caught string\n"); } catch(int) { // nothing } poll(0, 0, 5000); return 0; } int main() { pthread_t thr, thr2; pthread_create(&thr, 0, &func, 0); poll(0, 0, 1000); pthread_create(&thr2, 0, &func, 0); pthread_join(thr, 0); pthread_join(thr2, 0); return 0; } --Apple-Mail-1--163290563 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed This prevents any sort of complex exception-sensitive multithreaded C++ programs to run in Cygwin/GCC environment. Thanks for all your help, Lenny --Apple-Mail-1--163290563 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --Apple-Mail-1--163290563--