[ECOS] pthread_exit() and tss destructors

Nick Garnett nickg@redhat.com
Wed Feb 27 05:27:00 GMT 2002

Robin Farine <robin.farine@acn-group.ch> writes:

> Hi,
> Third-party code using POSIX threads and tss caused me some trouble when
> such a thread exited. It turned out that tss destructors got called
> multiple times for the same key. According to the POSIX 1003.1 standard,
> the code calling these destructors should set each value to NULL before
> calling the associated destructor.

It is my reading of the standard that it is the responsibility of the
destructor function itself to set the value to NULL, or some other
value. Otherwise there would be no need for {PTHREAD_DESTRUCTOR_ITERATIONS}.

There is nothing in the rationale about this either. This looks like
one of those situations where the POSIX standard is incompletely
specific. To be completely portable it looks like destructor code
cannot assume that the keys will be NULLed, and must do it itself with

Nick Garnett, eCos Kernel Architect
Red Hat, Cambridge, UK

Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

More information about the Ecos-discuss mailing list