Subject: [Boost-bugs] [Boost C++ Libraries] #5836: tss.cpp: tss_data_dec_use suffers a race condition
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-08-30 05:48:25
#5836: tss.cpp: tss_data_dec_use suffers a race condition
--------------------------------+-------------------------------------------
Reporter: noloader@⦠| Owner:
Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
Version: Boost 1.47.0 | Severity: Problem
Keywords: |
--------------------------------+-------------------------------------------
It appears the reference counting of tss_data_use suffers a race
condition. Perhaps it would be best to use an interlocked decrement on
tss_data_use:
{{{
void tss_data_dec_use(boost::mutex::scoped_lock& lk)
{
if (0 == --tss_data_use)
{
tss_data_cleanup_handlers_type::size_type i;
for (i = 0; i < tss_data_cleanup_handlers->size(); ++i)
{
delete (*tss_data_cleanup_handlers)[i];
}
delete tss_data_cleanup_handlers;
tss_data_cleanup_handlers = 0;
lk.unlock();
delete tss_data_mutex;
tss_data_mutex = 0;
#if defined(BOOST_HAS_WINTHREADS)
TlsFree(tss_data_native_key);
#elif defined(BOOST_HAS_PTHREADS)
pthread_key_delete(tss_data_native_key);
#elif defined(BOOST_HAS_MPTASKS)
// Don't know what to put here.
// But MPTASKS isn't currently maintained anyways...
#endif
}
}
}}}
In addition, it appears code built with BOOST_HAS_MPTASKS will fail in
unexpected ways. Perhaps it would be a good idea to create a compile time
failure to save users:
Index: tss.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/thread/src/tss.cpp,v
retrieving revision 1.20
diff -r1.20 tss.cpp
67a68
> #error "MPTASKS isn't currently maintained"
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5836> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC