Boost logo

Boost Users :

Subject: Re: [Boost-users] pthread_exit() from boost::thread segfaults
From: Peter Dimov (pdimov_at_[hidden])
Date: 2010-12-21 10:38:22


Viatcheslav.Sysoltsev wrote:
...
> void tf()
> {
> printf("thread\n");
> sleep(1);
> pthread_exit(NULL);
> }

pthread_exit in glibc/NPTL causes a "forced unwind" that is almost like a
C++ exception, but not quite. (And its semantics probably have changed since
last I looked.) Either way, a catch(...) clause that calls terminate(), as
in the earlier version of Boost, or no catch clause at all, as in the later
ones, should cause exactly the behavior you describe. Moving the cleanup
code into a destructor should work on Linux. It won't on Mac OS X, for
example, where pthread_exit unwinds without calling C++ destructors, as far
as I know. But then you'd have other problems too. :-)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net