From: Mike A. <ya...@ya...> - 2008-12-01 03:11:41
|
> I'd like stack unwinding to take place in *all* spawned threads As you discovered, ST has no knowledge of C++ exceptions. However, I think you may be relying on platform-specific behavior. My understanding of uncaught exceptions is that they result in terminate() being called, which defaults to abort(), which means no destructors are called for any objects. If you remove all the ST functions from your test program and simply throw an uncaught exception: [...] int main() { cleanup c; // st_init(); // st_thread_t t = st_thread_create(&f, (void*)"abc", 1, 0); // st_thread_join(t, NULL); f(NULL); return 0; } then c's destructor is not called either. This matches what my copy of Stroustrup says. Does something different happen on your system? On the other hand, if you were trying to have thread A *catch* an exception thrown by thread B, then I could understand your desire to have stack unwinding work properly and have object c's destructor called. But ST does not support propagating C++ exceptions across threads. ST does work just fine with C++ -- I have done so myself -- just not when it comes to exceptions crossing threads. |