[Boost-bugs] [Boost C++ Libraries] #5827: condition.cpp: condition_impl::notify_one swallows errors from WaitForSingleObject

Subject: [Boost-bugs] [Boost C++ Libraries] #5827: condition.cpp: condition_impl::notify_one swallows errors from WaitForSingleObject
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-08-30 03:15:05


#5827: condition.cpp: condition_impl::notify_one swallows errors from
WaitForSingleObject
------------------------------+---------------------------------------------
 Reporter: anonymous | Owner:
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
  Version: Boost 1.47.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------------------------
 condition_impl::notify_one silently swallows errors from
 WaitForSingleObject. The author got the asserts correct, but took no
 action on failures.

 My apologies for throwing a runtime_error. I'm not familiar enogh with
 boost to know what should be thrown. I also suspect the code should throw
 earlier than before function exit.

 Index: condition.cpp
 ===================================================================
 RCS file: /cvsroot/boost/boost/libs/thread/src/condition.cpp,v
 retrieving revision 1.21
 diff -r1.21 condition.cpp
 81,83c81,83
 < int res = 0;
 < res = WaitForSingleObject(reinterpret_cast<HANDLE>(m_mutex),
 INFINITE);
 < assert(res == WAIT_OBJECT_0);
 ---
> int wait1 = WAIT_OBJECT_0, wait2 = WAIT_OBJECT_0, res = 0;
> wait1 = WaitForSingleObject(reinterpret_cast<HANDLE>(m_mutex),
 INFINITE);
> assert(wait1 == WAIT_OBJECT_0);
 100,101c100,101
 < res = WaitForSingleObject(reinterpret_cast<HANDLE>(m_gate),
 INFINITE);
 < assert(res == WAIT_OBJECT_0);
 ---
> wait2 = WaitForSingleObject(reinterpret_cast<HANDLE>(m_gate),
 INFINITE);
> assert(wait2 == WAIT_OBJECT_0);
 126a127,132
>
> if(wait1 != WAIT_OBJECT_0)
> throw std::runtime_error("Failed to wait on mutex");
>
> if(wait2 != WAIT_OBJECT_0)
> throw std::runtime_error("Failed to wait on gate");

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