Re: C++ stack unwinding
Mike Abbott <[email protected]> Sun, 30 Nov 2008 21:11:33 -0600
| Newsgroups | gmane.comp.lib.state-threads.user |
|---|---|
| Message-ID | <[email protected]> |
> 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.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/