//fork/throw SEGFAULT issue //a SEGFAULT occurs under these circumstances: // 1. compile with g++-4 (4.3.4 20090804) on cygwin 1.7.5-1 // - g++-3 does not have this issue // - occurrences in cyg 1.7.4-1 were not reproducible (other causes?) // 2. fork at least once // 3. throw a derived exception class in the child // 4. where the derived class contains a std::string member // 5. catch std::exception //To see the SEGFAULT, you will need error_start=dumper.exe //or something similar in the CYGWIN environmental variable #include #include #include #include #include using namespace std; class stringexcept : public exception { public: stringexcept() : exception(), _what() {} virtual ~stringexcept() throw() {} string _what; }; int main(int, char**) { try { pid_t pid = fork(); if (pid == 0) { //child - throw and SEGFAULT throw stringexcept(); } else if (pid > 0) { //parent exit(0); } else { //fork() failed exit(1); } //if parent/child } catch(exception e) { //do nothing } return 0; }