Boost C++ Libraries: Ticket #11158: Pthread thread deadlock when faketime used https://svn.boost.org/trac10/ticket/11158 <p> Following code deadlocked on pthread_cond_timedwait call if started like </p> <pre class="wiki">LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1 FAKETIME="+30d" ./a.out </pre><pre class="wiki">#include &lt;boost/thread.hpp&gt; #include &lt;iostream&gt; using namespace std; void f() { int n=50; while (n--) { cout &lt;&lt; n &lt;&lt; endl; boost::this_thread::sleep(boost::posix_time::seconds(1)); // boost::this_thread::sleep_for( boost::chrono::seconds(1) ); // sleep(1); } } int main(int argc, char* argv[]) { boost::thread th(f); th.join(); return 0; } </pre><p> Here is backtarce: </p> <pre class="wiki">#0 pthread_cond_timedwait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:238 #1 0x0000000000da8ed3 in boost::condition_variable::do_wait_until(boost::unique_lock&lt;boost::mutex&gt;&amp;, timespec const&amp;) () #2 0x0000000000da792f in boost::this_thread::hiden::sleep_until(timespec const&amp;) () #3 0x0000000000978ff6 in boost::this_thread::sleep (abs_time=...) at /home/sl/project/Elephantdrive/devroot/3rdparty/boost/boost/thread/pthread/thread_data.hpp:249 #4 0x0000000000979065 in boost::this_thread::sleep&lt;boost::posix_time::seconds&gt; (rel_time=...) at /home/sl/project/Elephantdrive/devroot/3rdparty/boost/boost/thread/pthread/thread_data.hpp:255 </pre><p> But no deadlocks if used sleep(1) instead. I belive it is some pthread_cond_timedwait issue but will be good call sleep() or usleep() in boost's internals instead in according points if possible. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11158 Trac 1.4.3 viboes Sat, 04 Apr 2015 21:38:39 GMT <link>https://svn.boost.org/trac10/ticket/11158#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11158#comment:1</guid> <description> <p> Can you use </p> <pre class="wiki">boost::this_thread::no_interruption_point::sleep_for( boost::chrono::seconds(1) ); </pre><p> which is not interruptible and so don't need the use of cv? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 04 Apr 2015 21:38:46 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/11158#comment:2 https://svn.boost.org/trac10/ticket/11158#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> Ticket viboes Mon, 07 Sep 2015 17:50:42 GMT <link>https://svn.boost.org/trac10/ticket/11158#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11158#comment:3</guid> <description> <p> I've a patch that uses pthread_condattr_setclock. 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> can you check if this works for you? </p> <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> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 27 Sep 2015 13:29:26 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/11158#comment:4 https://svn.boost.org/trac10/ticket/11158#comment:4 <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> Ticket viboes Sun, 27 Sep 2015 13:41:10 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11158#comment:5 https://svn.boost.org/trac10/ticket/11158#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">fixed</span> </li> </ul> <blockquote> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/730cb550e6d969520c3f39e0ddf5d80351bddf3a"><span class="icon">​</span>https://github.com/boostorg/thread/commit/730cb550e6d969520c3f39e0ddf5d80351bddf3a</a> </p> </blockquote> Ticket