Mail Archives: cygwin/2006/06/22/14:34:46
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 <iostream>
#include <exception>
#include <Windows.h>
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/
- Raw text -