Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9787: [windows] Small duration value passed down to basic_timed_mutex::try_lock_until and condition_variable::wait_until can cause infinite or near infinite wait for win32
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-09-14 20:21:53
#9787: [windows] Small duration value passed down to
basic_timed_mutex::try_lock_until and condition_variable::wait_until can
cause infinite or near infinite wait for win32
-------------------------------------+-------------------------------------
Reporter: Bryan Laird | Owner: viboes
<bryan_laird@â¦> | Status: assigned
Type: Bugs | Component: thread
Milestone: To Be Determined | Severity: Problem
Version: Boost 1.53.0 | Keywords: WaitForSingleObject
Resolution: | timed_mutex try_lock_until
| wait_until
-------------------------------------+-------------------------------------
Comment (by viboes):
Could someone try this patch
{{{
git diff include/boost/thread/win32/basic_timed_mutex.hpp
diff --git a/include/boost/thread/win32/basic_timed_mutex.hpp
b/include/boost/thread/win32/basic_timed_mutex.hpp
index b55affd..d20c658 100644
--- a/include/boost/thread/win32/basic_timed_mutex.hpp
+++ b/include/boost/thread/win32/basic_timed_mutex.hpp
@@ -203,7 +203,12 @@ namespace boost
do
{
- chrono::milliseconds rel_time=
chrono::ceil<chrono::milliseconds>(tp-chrono::system_clock::now());
+ chrono::time_point<chrono::system_clock,
chrono::system_clock::duration> now = chrono::system_clock::now();
+ if (tp<=now) {
+ BOOST_INTERLOCKED_DECREMENT(&active_count);
+ return false;
+ }
+ chrono::milliseconds rel_time=
chrono::ceil<chrono::milliseconds>(tp-now);
if(win32::WaitForSingleObjectEx(sem,static_cast<unsigned
long>(rel_time.count()),0)!=0)
{
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9787#comment:8> 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:16 UTC