Boost logo

Boost :

From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2004-08-09 04:42:44

Roland wrote:
> While considering various ways to get rid of the remaining
> intentional memory leak of the tss implementation, I came
> upon the following question:
> How long may a thread access it's tss storage anyway?

Process termination aside for a moment, as long as it can

> I did not find anything in the documentation about the topic.
> Looking into the destructor of thread_specific_ptr reveals
> ~thread_specific_ptr() { reset(); }

The issue here is reuse of TSD keys. For keys without cleanup
(null TSD destructor), implementations shall ensure that appls
see nulls upon reuse. In the case of keys WITH cleanup (non-
null TSD destuctors), it is the responsibility of appls to
clear the slots (in all relevant threads) and perform cleanup
prior to TSD key destruction.
(Subject: Re: TSD key reuse)

> How is the situation for other libraries, say e.g. pthreads?
> Are they allowed to run after main ended?

Main (initial) *thread* is just a thread, nothing special.
Main *function* is special. Return from main is just like
calling exit() -- it evaporates all threads without
any thread cleanup. OTOH, mere termination of main/initial
thread (by means of pthread_exit() or thread cancellation),
has no effect with respect to other threads.


Boost list run by bdawes at, gregod at, cpdaniel at, john at