Re: [Boost-bugs] [Boost C++ Libraries] #6787: boost::thread::sleep() hangs if system time is rolled back

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6787: boost::thread::sleep() hangs if system time is rolled back
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-10-20 08:44:31


#6787: boost::thread::sleep() hangs if system time is rolled back
-----------------------------------------------+----------------------
  Reporter: Artem Gayardo-Matrosov <boost@…> | Owner: viboes
      Type: Bugs | Status: assigned
 Milestone: Boost 1.60.0 | Component: thread
   Version: Boost 1.49.0 | Severity: Problem
Resolution: | Keywords:
-----------------------------------------------+----------------------

Comment (by ueli.marti@…):

 I have made some further investigations and made some interesting
 findings. I didn't report back to you because i'm still not completely
 finished.[[BR]]
 The short story:[[BR]]
 The issue seems to be related to glibc/pthread and not the platform and
 not boost neither.[[BR]]


 The long story:[[BR]]
 I wrote a test program using directly the pthread api (as you
 suggested).[[BR]]
 I found that on ARM/Linux (platform P), when using CLOCK_REALTIME or
 default (not using pthread_condattr_setclock() at all),
 pthread_cond_timedwait() hangs when system clock is rolled back during the
 wait.[[BR]]
 Actually it doesn't really hang, it simply waits until system clock
 reaches the absolute time specified in the abstime argument of
 pthread_cond_timedwait().[[BR]]
 When using CLOCK_MONOTONIC, pthread_cond_timedwait() returns ETIMEDOUT
 after the time difference elapsed, independently of the system clock.
 That's the behavior i expect from this function.[[BR]]

 So: CLOCK_MONOTONIC is supported by this platform.[[BR]]
 Then, i put my test program on another ARM/Linux platform (platform D)
 using the same processor but another kernel and another rootfs.[[BR]]

 And then it becomes interesting: On platform D, even using CLOCK_REALTIME
 or default, pthread_cond_timedwait() DOESN'T hang if system clock is
 rolled back during the wait!!

 So i started to check the glibc/pthread versions.[[BR]]
 On platform P, i have 2.19[[BR]]
 On platform D, i have 2.16[[BR]]

 I managed to put version 2.17 on platform P and surprise,
 pthread_cond_timedwait() DOESN'T hang anymore.[[BR]]

 I then went on my Ubuntu 12.04 and checked glibc => 2.15 =>
 pthread_cond_timedwait() DOESN'T hang.[[BR]]
 I found an Ubuntu 14.04, glibc 2.19 => pthread_cond_timedwait() HANGS when
 system clock is rolled back!!

 I googled and tried to find any hint on this change of behavior of
 pthread_cond_timedwait() in the different glibc versions but couldn't find
 anything.[[BR]]

 At this stage, i'm trying to install the latest glibc (2.22) on my Ubuntu
 14.04 and check how it behaves.[[BR]]
 Then, i think it will be time to contact the glibc maintainers.[[BR]]

 In parallel, i plan to make some tests with the standard boost 1.59.0 on
 the different platforms and different glibc versions.[[BR]]

 That's about the state for the moment.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6787#comment:63>
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:19 UTC