Boost logo

Boost :

From: Roland (roland.schwarz_at_[hidden])
Date: 2003-12-17 05:41:19

(Michael Glassford <glassfordm_at_[hidden]>) wrote:

> On 12/14/2003, Martin Wille wrote:
> > I reported a Boost.Thread problem some time ago (the result of
> > m_tss.set() is not checked by thread_safe_ptr<>); no response from
> > the maintainer.
> In another thread on 11/18/2003, David Abrahams wrote:
> > Boost.Threads is languishing and its design has
> > frankly become too important to be allowed to do so.
> And in yet another thread on 8/21/2003, Hurd, Matthew wrote:
> > Just wondering on the status of the thread_dev branch...
> >
> > I use rw_mutex a bit and was wondering when it might be set for
> > officialdom. Very useful even in its dev state.
> >

I found myself, posting a suspected bug in the (Windows)TLS code, and
suggested how to get a the threads library into a static library on the
Windows platform. I never got any response. Perhaps is was ovelooked?
In case anyone does think it is not appropriate, please let me also know.

Maybe this is the time to try again?

1) My first mail reposted: (11/14/2003)

Dear Boosters!

As I am still trying to figure out how to use the thread local storage pointer I found another
strange behaviour. Perhaps I am misunderstanding the docs, or this might be a bug.
System: VC6.0 CVS Head

Problem: When using release on a tss variable, the associated automatic cleanup routine seems not to
be updated correctly as it tries to delete the original pointer, instead of the 0-pointer.

Example (simple modification of tss.cpp example):

boost::thread_specific_ptr<int> value;

void increment()
    int* p = value.get();

void thread_proc()
    value.reset(new int(0)); // initialize the thread's storage
    for (int i=0; i<10; ++i)
        int* p = value.get();
        assert(*p == i+1);
//******** added the following two lines
   int* p = value.release();
   delete p; // deleting the released pointer

int main(int argc, char* argv[])
    boost::thread_group threads;
    for (int i=0; i<5; ++i)

In the debug version the program faults at exit, as the pointers are beeing freed a second time.
I suspect the problem lies in the following function, as it does not set the cleanup handler if the
value is 0

bool tss::set(void* value)
    if (value && m_cleanup)
        cleanup_handlers* handlers = get_handlers();
        if (!handlers)
            return false;
        cleanup_info info(m_cleanup, value);
        (*handlers)[m_key] = info;
    return !!TlsSetValue(m_key, value);

Roland Schwarz

2) My second mail. Hmm I am wondering if this makes any sense, since I posted the files
already to Mike directly, but di not get an response. Michael did you receive them?
Should I repost them?

Best regards,

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