Boost logo

Boost :

From: Tony Juricic (tonygeek_at_[hidden])
Date: 2004-07-31 19:53:58


"Aaron W. LaFramboise" wrote:

>...
> -I think it might be possible for threads to die some other way. I
> don't think anything makes any guarantee that ExitThread and
> TerminateThread are the only ways a thread may exit. For example, a
> thread may be caused to exit by some lower-level API (perhaps a direct
> access to NTDLL).
> ...

Yes. ExitProcess, for example, will terminate all misbehaving threads. By
misbehaving I mean something from as dumb as thread procedure like:

while(true)
    ;

to complex thread procedures using locks, mutexes and so on.

I share your opinions about hooking API calls.

To summarize my own understanding (or misunderstanding) let me try classify
the problem issues:

1) TSS slot cleanup.
    1a) intentional leak of a 'hidden' native slot
    1b) cleanup of TSS slots reserved by boost::thread_specific_ptr<class T>

2) cleanup of objects stored in TSS slots.
    semi-sloppy thread procedures that forget reset like:
{
    if (ptr.get() == 0)
        ptr.reset(new Object());
    .... code
    // forgotten ptr.reset();
}

3) Thread (and process/main thread) exit notifications required for cleanup
    3a) semi-sloppy thread procedures will get TSS and objects cleaned up
    3b) misbehaving thread procedures leaking everything, including TSS

Tony


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk