[Boost-bugs] [Boost C++ Libraries] #5845: mutex.inl: wait_mutex (and its callers) ignore failures from WaitForSingleObject

Subject: [Boost-bugs] [Boost C++ Libraries] #5845: mutex.inl: wait_mutex (and its callers) ignore failures from WaitForSingleObject
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-08-30 08:10:40


#5845: mutex.inl: wait_mutex (and its callers) ignore failures from
WaitForSingleObject
--------------------------------+-------------------------------------------
 Reporter: noloader@… | Owner:
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
  Version: Boost 1.47.0 | Severity: Problem
 Keywords: |
--------------------------------+-------------------------------------------
 {{{
 inline int wait_mutex(void* mutex, int time)
 {
   unsigned int res = 0;
   res = WaitForSingleObject(mutex_cast(mutex), time);
   //:xxx assert(res != WAIT_FAILED && res != WAIT_ABANDONED);
   return res;
 }
 }}}

 Its callers are spread across a number of files, including mutex.cpp and
 recursive_mutex.cpp. Unfortunately, a common use case is shown below
 (taken from mutex.cpp):

 {{{
 void timed_mutex::do_lock()
 {
    wait_mutex(m_mutex, INFINITE);
 }
 }}}

 Not only does do_lock() ignore the return value, its callers will proceed
 to use the guarded data regardless of whether the lock was actually
 acquired.

 do_trylock() does a little better, but still ignores return values such as
 ERROR_INVALID_HANDLE and WAIT_FAILED.

 {{{
 bool timed_mutex::do_trylock()
 {
   return wait_mutex(m_mutex, 0) == WAIT_OBJECT_0;
 }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5845>
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