pthread_cleanup_push not working with uClibc

Rich Felker dalias at
Wed Feb 29 17:29:44 UTC 2012

On Wed, Feb 29, 2012 at 09:06:32AM -0500, Alan Cooper wrote:
> I seems to me there are 2 different issues here.
> 1. pthread_cleanup_push/pthread_cleanup_pop does not work for C++
> programs. The cleanup routine passed to pthread_cleanup_push will not
> be called when the thread is cancelled.
> 2. Class destructors for locally scoped (stack based) classes are not
> called when the thread is cancelled.
> Are you suggesting #1 is not a bug?

I'm saying that #1 is definitely a bug no matter what, but #2 is only
a bug in the sense that NPTL is trying to provide you an extra feature
outside the scope of the standard (and failing to do so). Relying on
#2 (and using cancellation in any situation where there are
destructors that would need to be called) is NOT PORTABLE and means
your program will only work on glibc (or, once it's fixed, uClibc)
based systems.


P.S. Please use the mailing list (reply to list, not to me).

More information about the uClibc mailing list