X-Spam-Check-By: sourceware.org From: kenelson8 AT comcast DOT net To: cygwin AT cygwin DOT com Subject: g++ 3.4.4, mingw32, exceptions and threads Date: Thu, 22 Jun 2006 18:34:24 +0000 Message-Id: <062220061834.3739.449AE2B000052C1600000E9B2209229927C802019C040A020A05@comcast.net> X-Mailer: AT&T Message Center Version 1 (Apr 11 2006) 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 I am having problems getting exceptions to work properly in the latest release of g++ distributed from cygwin. I have a multithreaded code which is built using the no-cygwin option. The code uses exceptions in a few places. Oddly the code is either crashing out right, or the exceptions are being delivered to the wrong thread. My search for answers through this archive and the web have been in fruitless. The keywords "thread" and "exception" are used too frequenty for other uses. I have been unable to find anyone responding to similar reports on other mailling lists. What I have found dates to the egcs days and is really not relevent. This is obviously a case where the mingw32 libgcc has been built without threadsafe exceptions. My question is there an option to compile mingw32 with threadsafe exception support? Are there plans to release a threadsafe compiled version in cygwin? If there is a way to build the libgcc and no plans for cygwin to release it, where do I find instructions on how to build it with threadsafty myself? I have included an example below. It appears to work without the -mno-cygwin option. With that option, it either runs incorrectly, crashes, or exits unexpectly depending on the phase of the moon. --Karl ------------------------------------------------------------------------ #include #include #include HANDLE thread_=0; int thread_go(void *) { for (int i=0;i<40 ; i++) { ::Sleep(250); try { throw std::exception(); } catch (std::exception& e) { std::cout << "Caught std::exception" << std::endl; } catch(...) { std::cout <<"Unhandled Exception" << std::endl; } } } int main() { thread_=::CreateThread(NULL,0, (LPTHREAD_START_ROUTINE) thread_go, 0, 0, NULL); ::Sleep(1000); try { throw int(10); } catch (int i) { std::cout << "main: caught int " << i << std::endl; } catch (...) { std::cout << "main: unexpected exception to main!" << std::endl; } std::cout << "sleep" << std::endl; ::Sleep(3000); std::cout << "done" << std::endl; } ---------------------------------------------------------------------- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/