Boost C++ Libraries: Ticket #6787: boost::thread::sleep() hangs if system time is rolled back https://svn.boost.org/trac10/ticket/6787 <p> Steps to reproduce: </p> <ol><li>Compile and run the following code <div class="wiki-code"><div class="code"><pre><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="k">while</span><span class="p">(</span><span class="nb">true</span><span class="p">)</span> <span class="p">{</span> <span class="n">printf</span><span class="p">(</span><span class="s">&quot;%d</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="o">++</span><span class="n">i</span><span class="p">);</span> <span class="n">boost</span><span class="o">::</span><span class="n">this_thread</span><span class="o">::</span><span class="n">sleep</span><span class="p">(</span> <span class="n">boost</span><span class="o">::</span><span class="n">posix_time</span><span class="o">::</span><span class="n">milliseconds</span><span class="p">(</span><span class="mi">1000</span><span class="p">));</span> <span class="p">}</span> </pre></div></div></li></ol><ol start="2"><li>While it runs, rewind the system time by 1 hour back. </li></ol><p> Expected result: The code continues to print every second. </p> <p> Actual result: The code stops printing anything. I doesn't continue even after I've put the time back to current. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6787 Trac 1.4.3 Artem Gayardo-Matrosov <boost@…> Fri, 13 Apr 2012 12:52:11 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:1</guid> <description> <p> The problem is specific to Linux; it seems to work fine on Windows. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 28 May 2012 15:56:53 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/6787#comment:2 https://svn.boost.org/trac10/ticket/6787#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> boost::this_thread::sleep will be deprecated since 1.50. Do you get the same behavior with </p> <p> boost::this_thread::sleep_for? </p> Ticket Artem Gayardo-Matrosov <boost@…> Tue, 19 Jun 2012 14:19:41 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:3</guid> <description> <p> I confirm the problem is no longer there with boost::this_thread::sleep_for(), as it uses the monotonic timer from the chrono lib. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 28 Jun 2012 11:24:08 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:4</guid> <description> <p> I'm thinking in deprecating the sleep function. Does sleep_for() respond to your needs? If yes, could we close this ticket as don't fixed as there is a better alternative? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 08 Jul 2012 16:05:18 GMT</pubDate> <title>status changed; resolution set; milestone deleted https://svn.boost.org/trac10/ticket/6787#comment:5 https://svn.boost.org/trac10/ticket/6787#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> <li><strong>milestone</strong> <span class="trac-field-deleted">To Be Determined</span> </li> </ul> Ticket Ki Hong Lee <clydelee@…> Mon, 09 Dec 2013 04:29:21 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:6</guid> <description> <p> This problem is being reoccurring again in the 1.55.0. </p> <ol><li>environment <ul><li>O/S : linux x86_64 (glibc 2.15) </li><li>compiler : gcc 4.7.3 </li></ul></li></ol> </description> <category>Ticket</category> </item> <item> <author>Ki Hong Lee <clydelee@…></author> <pubDate>Mon, 09 Dec 2013 04:41:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:7</guid> <description> <p> i'm missed an important point </p> <ol start="2"><li>Problem function boost::this_thread::sleep_for </li></ol> </description> <category>Ticket</category> </item> <item> <author>boost@…</author> <pubDate>Mon, 09 Dec 2013 10:29:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:8</guid> <description> <p> I would still fix boost::sleep() to use a monotonic timer, as it basically means that any calls to sleep() will hang your application randomly, for example if your system uses automatic time synchronization. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 09 Dec 2013 22:32:36 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/6787#comment:9 https://svn.boost.org/trac10/ticket/6787#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">wontfix</span> </li> </ul> <p> system_time is not monotonic. Please could you provide an reproducible example that shows the error on linux with sleep_for? I'm really interested in fixing it if I can reproduce it. </p> Ticket Ki Hong Lee <clydelee@…> Mon, 09 Dec 2013 23:51:12 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:10</guid> <description> <p> Steps to reproduce: </p> <ol><li>Compile and run the following code <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/thread.hpp&gt; void some_job() { while (true) { boost::this_thread::sleep_for(boost::chrono::seconds(1)); std::cout &lt;&lt; "i'm awaken !" &lt;&lt; std::endl; } } int main() { boost::thread thrd(some_job); thrd.join(); return 0; } </pre></li></ol><ol start="2"><li>While it runs, rewind the system time by 1 hour back. </li></ol><p> Expected result: thread(some_job) is an infinite loop.<br /> </p> <p> Actual result : thread(some_job) is blocked. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 10 Dec 2013 18:42:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:11</guid> <description> <p> Would you example work if you use the underlying platform functions? Do you know of an standard library implementation that don't suffer of this problem? </p> </description> <category>Ticket</category> </item> <item> <author>Ki Hong Lee <clydelee@…></author> <pubDate>Wed, 11 Dec 2013 01:26:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:12</guid> <description> <p> new example: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/thread.hpp&gt; // 1.55.0 void boost_func() { while (true) { // libs/thread/src/pthread/thread.cpp : 442 // while( thread_info-&gt;sleep_condition.do_wait_for(lk,ts)) {} boost::this_thread::sleep_for(boost::chrono::seconds(1)); std::cout &lt;&lt; "i'm boost_func !" &lt;&lt; std::endl; } } // Similar to the 1.51.0 version of the sleep_for void posix_func() { ::timespec tm, tm1; while (true) { tm.tv_sec = 1; tm.tv_nsec = 0; ::nanosleep(&amp;tm, &amp;tm1); std::cout &lt;&lt; "\ti'm posix_func !" &lt;&lt; std::endl; } } int main() { boost::thread_group threads; threads.create_thread(boost_func); threads.create_thread(posix_func); threads.join_all(); return 0; } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 14 Dec 2013 18:23:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:13</guid> <description> <p> next follows the whole code </p> <pre class="wiki"> void BOOST_THREAD_DECL sleep_for(const timespec&amp; ts) { boost::detail::thread_data_base* const thread_info=boost::detail::get_current_thread_data(); if(thread_info) { unique_lock&lt;mutex&gt; lk(thread_info-&gt;sleep_mutex); while( thread_info-&gt;sleep_condition.do_wait_for(lk,ts)) {} } else { if (boost::detail::timespec_ge(ts, boost::detail::timespec_zero())) { # if defined(BOOST_HAS_PTHREAD_DELAY_NP) # if defined(__IBMCPP__) BOOST_VERIFY(!pthread_delay_np(const_cast&lt;timespec*&gt;(&amp;ts))); # else BOOST_VERIFY(!pthread_delay_np(&amp;ts)); # endif # elif defined(BOOST_HAS_NANOSLEEP) // nanosleep takes a timespec that is an offset, not // an absolute time. nanosleep(&amp;ts, 0); # else mutex mx; unique_lock&lt;mutex&gt; lock(mx); condition_variable cond; cond.do_wait_for(lock, ts); # endif } } } </pre><p> sleep_for() is one of the predefined thread interruption points. It is not possible to use nanosleep and make it an interruption point. </p> <p> I would like to separate standard threads and interruptible threads, but this is not yet there. </p> <p> What can I can do is define two functions sleep_for and sleep_until on a different namespace </p> <pre class="wiki">namespace non_interruptible { template &lt;class Clock, class Duration&gt; void sleep_until(const chrono::time_point&lt;Clock, Duration&gt;&amp; t); template &lt;class Rep, class Period&gt; void sleep_for(const chrono::duration&lt;Rep, Period&gt;&amp; d); } </pre><p> What do you think? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 09 Feb 2014 03:35:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:14</guid> <description> <p> Ping!!! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 26 Feb 2014 21:41:12 GMT</pubDate> <title>milestone set https://svn.boost.org/trac10/ticket/6787#comment:15 https://svn.boost.org/trac10/ticket/6787#comment:15 <ul> <li><strong>milestone</strong> → <span class="trac-field-new">To Be Determined</span> </li> </ul> Ticket viboes Sun, 06 Jul 2014 10:18:32 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:16</guid> <description> <p> It seems that there is an alternative as described in <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7665" title="#7665: Bugs: this_thread::sleep_for no longer uses steady_clock in thread (closed: fixed)">#7665</a>. (Is it possible to initialize the condition variable to use the monotonic clock as described <a class="ext-link" href="http://stackoverflow.com/questions/11893992/implementing-condition-variable-timed-wait-correctly"><span class="icon">​</span>here</a>). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 06 Jul 2014 11:17:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:17 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:17</guid> <description> <p> Unfortunately pthread_condattr_setclock is not available on <a class="missing wiki">MacOs</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 10 Sep 2014 11:50:57 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/6787#comment:18 https://svn.boost.org/trac10/ticket/6787#comment:18 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.57.0</span> </li> </ul> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/8440e9a7d83ea8ddefe7cf875f2caa2e8356481f"><span class="icon">​</span>https://github.com/boostorg/thread/commit/8440e9a7d83ea8ddefe7cf875f2caa2e8356481f</a> </p> Ticket viboes Tue, 16 Sep 2014 06:21:34 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6787#comment:19 https://svn.boost.org/trac10/ticket/6787#comment:19 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket Michael Sternberg Sun, 07 Dec 2014 07:04:53 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:20 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:20</guid> <description> <p> The problem still wasn't fixed when boost::this_thread::sleep is running in thread. Consider the following piece of code, sleep still hangs when system is rolled backwards: </p> <p> #include &lt;stdio.h&gt; #include &lt;boost/thread.hpp&gt; int i = 0; void testfunc() { </p> <blockquote> <p> while(true) { </p> <blockquote> <p> printf("%d\n", ++i); boost::this_thread::sleep( boost::posix_time::milliseconds(800)); </p> </blockquote> <p> } </p> </blockquote> <p> } </p> <p> int main() { </p> <blockquote> <p> boost::thread * th = new boost::thread(&amp;testfunc); th-&gt;join(); return 0; </p> </blockquote> <p> } </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 07 Dec 2014 13:18:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:21 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:21</guid> <description> <p> Let me know if the problem is still there with non_interruptible::sleep_for. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matulis</dc:creator> <pubDate>Mon, 08 Dec 2014 20:42:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:22 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:22</guid> <description> <p> I am also still seeing the same behavior when using sleep_for and no_interruption_point::sleep_for </p> <p> std::this_thread::sleep_for seems to be working, however I have to add in a _GLIBCXX_USE_NANOSLEEP define due to a bug in my version of GCC. </p> <p> Kernel: 2.6.32-431.29.2.el6.x86_64 GCC: 4.7.0 OS: CentOS 6.5 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matulis</dc:creator> <pubDate>Mon, 08 Dec 2014 21:07:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:23 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:23</guid> <description> <p> Testing with the preprocessor variable: BOOST_THREAD_SLEEP_FOR_IS_STEADY </p> <p> Seems to produce the same results </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 09 Dec 2014 06:34:00 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/6787#comment:24 https://svn.boost.org/trac10/ticket/6787#comment:24 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> Even with boost::this_thread::no_interruption_point::sleep_for? </p> <p> Well, it is not easy to manage the specific GCC bugs. </p> Ticket Matulis Tue, 09 Dec 2014 15:17:06 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:25 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:25</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6787#comment:24" title="Comment 24">viboes</a>: </p> <blockquote class="citation"> <p> Even with boost::this_thread::no_interruption_point::sleep_for? </p> <p> Well, it is not easy to manage the specific GCC bugs. </p> </blockquote> <p> And what I meant with the GCC comment, is that the only way I have gotten the situation to work correctly is if I used std::this_thread::sleep_for(). </p> <p> Yes, even with boost::this_thread::no_interruption_point::sleep_for: </p> <p> Here is the sample code(modified from an above example) </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/thread.hpp&gt; using namespace std; void testfunc() { int i = 0; while(true) { //Turn system clock back now and loop will no longer print std::cout &lt;&lt; "Testing: " &lt;&lt; i &lt;&lt; std::endl; boost::this_thread::no_interruption_point::sleep_for( boost::chrono::milliseconds(800)); i++; } } int main() { boost::thread th = boost::thread(&amp;testfunc); th.join(); return 0; } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 09 Dec 2014 19:01:36 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:26 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:26</guid> <description> <p> Did you defined _GLIBCXX_USE_NANOSLEEP when using boost::this_thread::no_interruption_point::sleep_for? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matulis</dc:creator> <pubDate>Tue, 09 Dec 2014 19:17:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:27 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:27</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6787#comment:26" title="Comment 26">viboes</a>: </p> <blockquote class="citation"> <p> Did you defined _GLIBCXX_USE_NANOSLEEP when using boost::this_thread::no_interruption_point::sleep_for? </p> </blockquote> <blockquote> <p> I am seeing the same result whether it is defined or not. In regard to the overall problem, can you reproduce the same results on your machine? </p> </blockquote> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 09 Dec 2014 22:34:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:28 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:28</guid> <description> <p> A test example changing itself the date would be welcome. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matulis</dc:creator> <pubDate>Wed, 10 Dec 2014 16:13:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:29 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:29</guid> <description> <p> Here is some test code that modifies the system time backwards by 1 minute, however you need to run it as sudo/root, due to the use of stime. I link to boost_chrono, so I don't have to create edge cases for when the hour/day/month changes. </p> <p> Expected Result: Loop in thread should continuously keep printing out messages </p> <p> Actual Result: After system time is changed, the loop does not execute until system time catches back up to present time </p> <p> If I have time later, I could try to integrate it into the unit tests, let me know if that would be useful. </p> <div class="wiki-code"><div class="code"><pre> <span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;time.h&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/thread.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/chrono.hpp&gt;</span><span class="cp"></span> <span class="kt">void</span> <span class="nf">testfunc</span><span class="p">()</span> <span class="p">{</span> <span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="k">while</span><span class="p">(</span><span class="nb">true</span><span class="p">)</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;Testing: &quot;</span> <span class="o">&lt;&lt;</span> <span class="n">i</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span> <span class="n">boost</span><span class="o">::</span><span class="n">this_thread</span><span class="o">::</span><span class="n">no_interruption_point</span><span class="o">::</span><span class="n">sleep_for</span><span class="p">(</span> <span class="n">boost</span><span class="o">::</span><span class="n">chrono</span><span class="o">::</span><span class="n">milliseconds</span><span class="p">(</span><span class="mi">1000</span><span class="p">));</span> <span class="n">i</span><span class="o">++</span><span class="p">;</span> <span class="p">}</span> <span class="p">}</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="n">boost</span><span class="o">::</span><span class="kr">thread</span> <span class="n">th</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="kr">thread</span><span class="p">(</span><span class="o">&amp;</span><span class="n">testfunc</span><span class="p">);</span> <span class="c1">//Sleep thread to allow other thread to run for a bit before time is changed</span> <span class="n">boost</span><span class="o">::</span><span class="n">this_thread</span><span class="o">::</span><span class="n">sleep_for</span><span class="p">(</span><span class="n">boost</span><span class="o">::</span><span class="n">chrono</span><span class="o">::</span><span class="n">milliseconds</span><span class="p">(</span><span class="mi">5000</span><span class="p">));</span> <span class="n">boost</span><span class="o">::</span><span class="n">chrono</span><span class="o">::</span><span class="n">time_point</span><span class="o">&lt;</span><span class="n">boost</span><span class="o">::</span><span class="n">chrono</span><span class="o">::</span><span class="n">system_clock</span><span class="o">&gt;</span> <span class="n">current</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">chrono</span><span class="o">::</span><span class="n">system_clock</span><span class="o">::</span><span class="n">now</span><span class="p">();</span> <span class="c1">//Set time back 1 minute</span> <span class="n">current</span><span class="p">.</span><span class="k">operator</span> <span class="o">-=</span><span class="p">(</span><span class="n">boost</span><span class="o">::</span><span class="n">chrono</span><span class="o">::</span><span class="n">minutes</span><span class="p">(</span><span class="mi">1</span><span class="p">));</span> <span class="c1">//Create std time structure from boost chrono</span> <span class="n">std</span><span class="o">::</span><span class="kt">time_t</span> <span class="n">now</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">chrono</span><span class="o">::</span><span class="n">system_clock</span><span class="o">::</span><span class="n">to_time_t</span><span class="p">(</span><span class="n">current</span><span class="p">);</span> <span class="c1">//Set the system time</span> <span class="n">stime</span><span class="p">(</span><span class="o">&amp;</span><span class="n">now</span><span class="p">);</span> <span class="n">th</span><span class="p">.</span><span class="n">join</span><span class="p">();</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 10 Dec 2014 18:53:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:30 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:30</guid> <description> <p> Thnaks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 02 Feb 2015 06:33:20 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:31 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:31</guid> <description> <p> Could you add </p> <pre class="wiki">#ifndef BOOST_THREAD_SLEEP_FOR_IS_STEADY #error #endif </pre><p> and replace the call to sleep_for by </p> <pre class="wiki"> timespec ts = boost::detail::to_timespec(boost::chrono::milliseconds(1000)); nanosleep( &amp;ts, 0); </pre><p> ? </p> <p> The program must compile and run as you expect. It it is not the case you need to make it work as you expect before. </p> <p> Have you re built the Boost library after changing your compiler flags? If not do it, otherwise the code will not use nanosleep :( </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 02 Feb 2015 06:34:28 GMT</pubDate> <title>type changed https://svn.boost.org/trac10/ticket/6787#comment:32 https://svn.boost.org/trac10/ticket/6787#comment:32 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Support Requests</span> </li> </ul> <p> Moved to support, as I believe this is an issue on the configuration on the user side </p> Ticket Matulis Wed, 04 Feb 2015 17:48:33 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:33 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:33</guid> <description> <p> So I added in the requested code, it seems like there was no error on BOOST_THREAD_SLEEP_FOR_IS_STEADY </p> <p> And the execution worked correctly, with the nanosleep. </p> <p> However when I recompile my boost libraries with: </p> <p> ./b2 toolset=gcc-4.8.2 cxxflags="-std=c++11 -std=c++0x -v" define="_GLIBCXX_USE_NANOSLEEP" -a </p> <p> I still get the same issue when using: </p> <p> boost::this_thread::no_interruption_point::sleep_for( boost::chrono::milliseconds(800)); </p> <p> or </p> <p> boost::this_thread::sleep_for( boost::chrono::milliseconds(800)); </p> <p> Any ideas? So you are not seeing this issue when running the program as sudo? Since the system time will not change if you don't have elevated permissions. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Matulis</dc:creator> <pubDate>Wed, 04 Feb 2015 21:31:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:34 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:34</guid> <description> <p> I think the cause may have been an incorrect namespace when calling: </p> <pre class="wiki">boost::this_thread::no_interruption_point::sleep_for( boost::chrono::milliseconds(1000)); </pre><p> I created the following pull request: github.com/boostorg/thread/pull/45 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 04 Feb 2015 21:34:49 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:35 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:35</guid> <description> <p> You are right. I've accepted the PR. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 04 Feb 2015 21:38:20 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/6787#comment:36 https://svn.boost.org/trac10/ticket/6787#comment:36 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.57.0</span> → <span class="trac-field-new">Boost 1.58.0</span> </li> </ul> Ticket viboes Thu, 05 Feb 2015 06:57:15 GMT type changed https://svn.boost.org/trac10/ticket/6787#comment:37 https://svn.boost.org/trac10/ticket/6787#comment:37 <ul> <li><strong>type</strong> <span class="trac-field-old">Support Requests</span> → <span class="trac-field-new">Bugs</span> </li> </ul> Ticket viboes Sun, 08 Mar 2015 22:15:46 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6787#comment:38 https://svn.boost.org/trac10/ticket/6787#comment:38 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket ueli.marti@… Fri, 07 Aug 2015 09:47:16 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:39 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:39</guid> <description> <p> Seems the problem still subsists with Boost 1.58.0 with boost::this_thread::sleep_for(). It works with boost::this_thread::no_interruption_point::sleep_for(). Tested platform is: ARM, Linux 2.6.32, gcc 4.7.3, boost 1.58.0 </p> <p> Is boost 1.58.0 fixing the problem for boost::this_thread::sleep_for() or not ? </p> </description> <category>Ticket</category> </item> <item> <author>ueli.marti@…</author> <pubDate>Tue, 11 Aug 2015 06:07:39 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/6787#comment:40 https://svn.boost.org/trac10/ticket/6787#comment:40 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> Ticket viboes Thu, 13 Aug 2015 06:43:54 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:41 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:41</guid> <description> <p> Well, the fix is to use the no_interruption_point version. Unfortunately, there is no way to fix it for boost::this_thread::sleep_for(), thus the introduced no_interruption_point version. </p> </description> <category>Ticket</category> </item> <item> <author>ueli.marti@…</author> <pubDate>Thu, 13 Aug 2015 07:44:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:42 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:42</guid> <description> <p> Ok, i see. Thanks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 03 Sep 2015 20:56:32 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/6787#comment:43 https://svn.boost.org/trac10/ticket/6787#comment:43 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.58.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> <p> I'm writing a patch that uses pthread_condattr_setclock. As I said I have no platform providing it (I'm using MacOS). The user will need to define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC until I find a way to detect it. </p> <p> Is there any one that can test it? </p> Ticket viboes Sat, 05 Sep 2015 14:21:08 GMT status changed https://svn.boost.org/trac10/ticket/6787#comment:44 https://svn.boost.org/trac10/ticket/6787#comment:44 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">new</span> </li> </ul> <p> Add to develop branch <a class="ext-link" href="https://github.com/boostorg/thread/commit/9f883f6ad7377b88b79fa70cc5de68cbfb0213e4"><span class="icon">​</span>https://github.com/boostorg/thread/commit/9f883f6ad7377b88b79fa70cc5de68cbfb0213e4</a> </p> Ticket ueli.marti@… Mon, 07 Sep 2015 06:35:42 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:45 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:45</guid> <description> <p> I should be able to test it on ARM/Linux. Might take me a couple days however because i'm on other urgent issues. What's the best way to integrate you patch ? Can i just take boost 1.59 and replace condition_variable_fwd.hpp with your version ? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 07 Sep 2015 17:39:25 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:46 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:46</guid> <description> <p> Hi, I guess this should work. IN this case you can also add directly the define at the beginning of the file </p> <pre class="wiki">#define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 08 Sep 2015 19:42:41 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/6787#comment:47 https://svn.boost.org/trac10/ticket/6787#comment:47 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket ueli.marti@… Wed, 16 Sep 2015 14:32:25 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:48 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:48</guid> <description> <p> I've tested on ARM/Linux. boost::this_thread::sleep_for() hangs forever, even without rolling back system clock. </p> <p> Integrated the patch the following way: </p> <ul><li>downloaded boost 1.59.0 </li><li>replaced /thread/pthread/condition_variable_fwd.hpp with the version from the patch </li><li>added #define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC at the beginning of the file </li><li>rebuilt boost for target </li><li>rebuilt test program </li></ul> </description> <category>Ticket</category> </item> <item> <author>ueli.marti@…</author> <pubDate>Wed, 16 Sep 2015 14:44:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:49 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:49</guid> <description> <p> However, boost::thread::interrupt() allows to termionate boost::this_thread::sleep_for() </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 16 Sep 2015 18:06:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:50 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:50</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6787#comment:49" title="Comment 49">ueli.marti@…</a>: </p> <blockquote class="citation"> <p> However, boost::thread::interrupt() allows to termionate boost::this_thread::sleep_for() </p> </blockquote> <p> Glad to hear that. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 16 Sep 2015 18:08:36 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:51 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:51</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6787#comment:48" title="Comment 48">ueli.marti@…</a>: </p> <blockquote class="citation"> <p> I've tested on ARM/Linux. boost::this_thread::sleep_for() hangs forever, even without rolling back system clock. </p> <p> Integrated the patch the following way: </p> <ul><li>downloaded boost 1.59.0 </li><li>replaced /thread/pthread/condition_variable_fwd.hpp with the version from the patch </li><li>added #define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC at the beginning of the file </li><li>rebuilt boost for target </li><li>rebuilt test program </li></ul></blockquote> <p> Thanks for testing. Hrr, this are bad news. I will need to have access to a platform providing BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC. </p> </description> <category>Ticket</category> </item> <item> <author>ueli.marti@…</author> <pubDate>Thu, 17 Sep 2015 05:53:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:52 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:52</guid> <description> <p> Let me know if i can be of any help, if you want me to try out any changes. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 17 Sep 2015 17:49:38 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:53 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:53</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6787#comment:52" title="Comment 52">ueli.marti@…</a>: </p> <blockquote class="citation"> <p> Let me know if i can be of any help, if you want me to try out any changes. </p> </blockquote> <p> Thanks for the proposal. I'm a little bit busy fro two weeks. I'll come back to you then. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 17 Sep 2015 18:03:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:54 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:54</guid> <description> <blockquote> <p> Curiously the patch works for another tester <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/11377" title="#11377: Bugs: Boost condition variable always waits for system clock deadline (closed: fixed)">#11377</a>. </p> </blockquote> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 23 Sep 2015 23:01:30 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:55 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:55</guid> <description> <p> Please could you try to replace in thread/v2/thread.hpp line <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/94" title="#94: Tasks: Better reporting of failed expectation. (closed: wontfix)">#94</a> </p> <p> #ifdef BOOST_THREAD_SLEEP_FOR_IS_STEADY </p> <p> by </p> <p> #if defined BOOST_THREAD_SLEEP_FOR_IS_STEADY &amp;&amp; ! defined BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Fri, 25 Sep 2015 05:41:13 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/6787#comment:56 https://svn.boost.org/trac10/ticket/6787#comment:56 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> </ul> <p> Please, could you try the develop branch </p> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/8f5de1d7c34ff7248261874f273498a622bf76d4"><span class="icon">​</span>https://github.com/boostorg/thread/commit/8f5de1d7c34ff7248261874f273498a622bf76d4</a> </p> Ticket ueli.marti@… Fri, 25 Sep 2015 10:13:13 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:57 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:57</guid> <description> <p> Tested this </p> <blockquote> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/8f5de1d7c34ff7248261874f273498a622bf76d4"><span class="icon">​</span>https://github.com/boostorg/thread/commit/8f5de1d7c34ff7248261874f273498a622bf76d4</a> </p> </blockquote> <p> on ARM/Linux. Problem is still the same: boost::this_thread::sleep_for() hangs if system clock is rolled back, returns if clock rolled forward again. Now a question: Is it enough to #define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC in my code or does it have to be defined when building boost ? In the latter case, where to put this #define ? </p> <p> Information: With boost 1.59.0 on i386/Ubuntu 12.04 the behavior of boost::this_thread::sleep_for()is correct, no impact when rolling back the system clock. The problem seems specific to ARM. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 27 Sep 2015 13:38:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:58 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:58</guid> <description> <blockquote> <p> You need to define it before including any Boost file. </p> </blockquote> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 27 Sep 2015 13:39:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:59 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:59</guid> <description> <p> Could you test if the pthread interface works in ARM/Linux? </p> </description> <category>Ticket</category> </item> <item> <author>ueli.marti@…</author> <pubDate>Mon, 28 Sep 2015 08:42:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:60 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:60</guid> <description> <p> I have tried to #define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC in my code before any #include &lt;boost/...&gt;. </p> <p> When compiling my code for ARM/Linux, i get "undefined reference to boost::chrono::steady_clock::now()" in boost/thread/v2/thread.hpp on lines 90 and 130. (it compiles ok for i386/Ubunti 12.04). </p> <p> What do you mean exactly with testing pthread interface in ARM/Linux? Basically it works, i can greate threads, terminate them, join them etc. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 20 Oct 2015 07:38:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:61 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:61</guid> <description> <p> Sorry for the late response. </p> <p> I meant if you write the same program using directly the pthread set clock monotonic, </p> <pre class="wiki"> namespace detail { inline int monotonic_pthread_cond_init(pthread_cond_t&amp; cond) { #ifdef BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC pthread_condattr_t attr; int res = pthread_condattr_init(&amp;attr); if (res) { return res; } pthread_condattr_setclock(&amp;attr, CLOCK_MONOTONIC); res=pthread_cond_init(&amp;cond,&amp;attr); pthread_condattr_destroy(&amp;attr); return res; #else return pthread_cond_init(&amp;cond,NULL); #endif } } </pre><p> But don't compiling and hanging is not the same. </p> <p> I guess that that your ARM/linux doesn't supports monotonic clocks. </p> <p> I need to protect line 130 with BOOST_CHRONO_HAS_CLOCK_STEADY </p> <p> You can change </p> <pre class="wiki"> system_clock::time_point c_timeout = system_clock::now() + ceil&lt;nanoseconds&gt;(d); </pre><p> but no chance to fix the ticket issue on this platform. You will need to use no_interruption_point::sleep_for on this platform which of course is not interruptible. </p> <p> I will update v2/thread.hpp to make use of system_clock when there is no steady_clock. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 20 Oct 2015 08:04:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:62 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:62</guid> <description> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/dcc32276686e821d68cba5c3c8d587c3cb60d3b6"><span class="icon">​</span>https://github.com/boostorg/thread/commit/dcc32276686e821d68cba5c3c8d587c3cb60d3b6</a> </p> </description> <category>Ticket</category> </item> <item> <author>ueli.marti@…</author> <pubDate>Tue, 20 Oct 2015 08:44:30 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:63 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:63</guid> <description> <p> 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 /> </p> <p> 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 /> </p> <p> 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 /> </p> <p> 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!! </p> <p> 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 /> </p> <p> I managed to put version 2.17 on platform P and surprise, pthread_cond_timedwait() DOESN'T hang anymore.<br /> </p> <p> I then went on my Ubuntu 12.04 and checked glibc =&gt; 2.15 =&gt; pthread_cond_timedwait() DOESN'T hang.<br /> I found an Ubuntu 14.04, glibc 2.19 =&gt; pthread_cond_timedwait() HANGS when system clock is rolled back!! </p> <p> 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 /> </p> <p> 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 /> </p> <p> In parallel, i plan to make some tests with the standard boost 1.59.0 on the different platforms and different glibc versions.<br /> </p> <p> That's about the state for the moment. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 20 Oct 2015 15:56:08 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:64 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:64</guid> <description> <p> Thanks for the report. </p> <p> Please, either do your test with develop branch or wait until boost.1.60 is released as there are some fixes around this issue. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 21 Oct 2015 22:22:16 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6787#comment:65 https://svn.boost.org/trac10/ticket/6787#comment:65 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket ueli.marti@… Tue, 27 Oct 2015 10:49:54 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:66 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:66</guid> <description> <p> I made some tests with develop branch on following platforms:<br /> ARM/Linux, glibc 2.17<br /> ARM/Linux, glibc 2.19<br /> i386/Ubuntu 12.04, glibc 2.17<br /> i386/Ubuntu 14.04, glibc 2.19<br /> i386/Ubuntu 15.04, glibc 2.21<br /> <br /> Without any special #define we have the same behavior with boost.1.59 and with develop branch: </p> <ul><li>On all platforms with glibc 2.17, if system clock is rolled back during boost::this_thread::sleep_for() or boost::condition_variable::timedWait(), the sleep/wait terminates after the initially specified duration (expected behavior)<br /> </li><li>On all other platforms (glibc 2.19 or 2.21), if system clock is rolled back during boost::this_thread::sleep_for() or boost::condition_variable::timedWait(), the sleep/wait "hangs", i.e. terminates only when the initial time + duration is expired<br /> </li></ul><p> With develop branch and #define BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC the behavior is the same for all tested platforms:<br /> </p> <ul><li>boost::this_thread::sleep_for() terminates after the initially specified duration (expected behavior)<br /> </li><li>boost::condition_variable::timedWait() does never timeout, even without touching system clock. The wait can be terminated only by signalling the condition variable or by interrupting the thread.<br /> </li></ul><p> I then tested the native api pthread_cond_timedwait() directly, with pthread_condattr_setclock(CLOCK_MONOTONIC).<br /> On all platforms the behavior is as i expect it: if system clock is rolled back during pthread_cond_timedwait() the wait terminates after the initially specified duration<br /> <br /> I will repeat my tests when boost 1.60 is released.<br /> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Fri, 04 Nov 2016 00:10:49 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/6787#comment:67 https://svn.boost.org/trac10/ticket/6787#comment:67 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> Ticket viboes Fri, 04 Nov 2016 00:11:16 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:68 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:68</guid> <description> <p> Sorry for this. I missed this closed ticket. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 19 Feb 2017 10:55:38 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:69 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:69</guid> <description> <p> Please, could you check if </p> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/544eda51bdf0c62b2f29dea6fe1cf935ad62580e"><span class="icon">​</span>https://github.com/boostorg/thread/commit/544eda51bdf0c62b2f29dea6fe1cf935ad62580e</a> </p> <p> could solve the issue? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 19 Feb 2017 10:58:19 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/6787#comment:70 https://svn.boost.org/trac10/ticket/6787#comment:70 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.60.0</span> → <span class="trac-field-new">Boost 1.64.0</span> </li> </ul> Ticket viboes Fri, 24 Feb 2017 14:31:08 GMT <link>https://svn.boost.org/trac10/ticket/6787#comment:71 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:71</guid> <description> <p> I've rolled back the last change as it seems it introduce a regression. I need to check more deeply all the usage of timespace_now :( </p> <blockquote> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/9bbf9bed80836282263ec0bdea0adf5c1fa3621b"><span class="icon">​</span>https://github.com/boostorg/thread/commit/9bbf9bed80836282263ec0bdea0adf5c1fa3621b</a> </p> </blockquote> </description> <category>Ticket</category> </item> <item> <author>anton.indrawan@…</author> <pubDate>Mon, 15 May 2017 21:34:22 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:72 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:72</guid> <description> <p> I encountered the same issue. When I defined BOOST_THREAD_HAS_CONDATTR_SET_CLOCK_MONOTONIC , boost::this_thread::sleep_for blocks indefinitely. Is there any patch for this issue? I use boost 1.63. </p> </description> <category>Ticket</category> </item> <item> <author>anton.indrawan@…</author> <pubDate>Tue, 16 May 2017 15:01:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6787#comment:73 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6787#comment:73</guid> <description> <p> The following patch works for me. </p> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/c7348b29cf8bfa1272645d04784419d37e1e7db5"><span class="icon">​</span>https://github.com/boostorg/thread/commit/c7348b29cf8bfa1272645d04784419d37e1e7db5</a> </p> <p> Test environment: </p> <ul><li>Ubuntu 14.04 x64 </li><li>Boost 1.63 </li></ul> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 24 Jun 2017 14:35:25 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/6787#comment:74 https://svn.boost.org/trac10/ticket/6787#comment:74 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.64.0</span> → <span class="trac-field-new">Boost 1.65.0</span> </li> </ul> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/d4cff01c724f1355fef0990f3d6d678e52f61fd0"><span class="icon">​</span>https://github.com/boostorg/thread/commit/d4cff01c724f1355fef0990f3d6d678e52f61fd0</a> </p> Ticket viboes Sat, 24 Jun 2017 14:55:51 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6787#comment:75 https://svn.boost.org/trac10/ticket/6787#comment:75 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket