[boost] Bug in Win32 implementation of thread_specific_ptr
(detail::tss::set)
by Christof Meerwald other posts by this author
Jun 10 2002 3:31PM messages near this date
Re: [boost] Postfix Increment Operator
|
Re: [boost] Bug in Win32 implementation of
thread_specific_ptr(detail::tss::set)
Hi,
currently, detail::tss::set doesn't remove the previously registered
cleanup handler if the new value is a NULL pointer. So if you reset
a thread_specific_pointer with a NULL pointer (or release it) and don't
set any other value before the thread terminates, the initial pointer
will be deleted twice (once by thread_specific_pointer::reset and again
by the cleanup handler).
Shouldn't the implementation of tss::set (for Win32) be changed to
something like (completely untested):
bool tss::set(void* value)
{
if (m_cleanup)
{
cleanup_handlers* handlers = get_handlers();
assert(handlers);
if (!handlers)
return false;
if (value)
{
cleanup_info info(m_cleanup, value);
(*handlers)[m_key] = info;
}
else if (TlsGetValue(m_key))
{
handlers-> erase(m_key);
}
}
return !!TlsSetValue(m_key, value);
}
bye, Christof
--
http://cmeerw.org JID: cmeerw@[...].at
mailto cmeerw at web.de
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Christof Meerwald
Mark Rodgers
William E. Kempf
William E. Kempf
|