I debugging a target compiled by gcc44 on mac os x10.6.2
And my exception can't be caught. Program always terminate with
"Abort Trap". gdb catches SIGTRAP
I do demo about exception, throw from recursive function, from anthoer function , from deeeper function, but got nothing. So I trun to google and then I got "http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42159"
A 64 bit build of gcc 4.4.2 installed via darwinports on a Mac Pro server
running Snow Leopard 10.6.2 causes a crash in the following program:
>cat src/test.cpp
#include <iostream>
struct X
{
~X () // crash disappears if there is no destructor
{
}
};
void
dummy ()
{
X x;
throw 0;
}
int main()
{
try
{
dummy ();
}
catch (...)
{
std::cout << "CAUGHT" << std::endl;
}
return 0;
}
Instead of the expected "CAUGHT" the system pops up with:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
////////////////
but some guy said :
I can confirm the bug on my system (MacOS 10.6.3, Intel Core i7) with g++
4.4.2, 4.4.3 and 4.4.4.
However, I have discovered a workaround. Linking with -lpthread makes the
problem go away, both for this simple test case, and my larger program where I
too discovered the bug. My program only started failing when I turned off the
OpenMP stuff. However, if I leave OpenMP off, but link with -lpthread anyway,
the exception stuff works fine. Likewise, this example program works correctly
Yep, I throw an exception from thread but I can't sure this is the issuse, I'll try tomorrow.
So, good night!
when I compile with -lpthread.
More detail pls refers from "http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42159"" and it's description