Boost C++ Libraries: Ticket #2330: thread::interrupt() can be lost if condition_variable::wait() in progress https://svn.boost.org/trac10/ticket/2330 <p> In the pthread implementation of thread, if thread::interrupt() calls pthread_cond_broadcast() after condition_variable::wait() has checked for interrupt_requested and set current_cond but before it has called pthread_cond_wait(), the the cond_broadcast will be ignored and the wait will never terminate. </p> <p> I have observed this behavior under Cygwin (with Windows XP/SP3). In my application it causes the program to hang in the join of the waiting thread. </p> <p> I think that thread::interrupt() must own the mutex associated with current_cond when pthread_cond_broadcast() is called. (Note that if thread_info-&gt;data_mutex is owned when the current_cond mutex is acquired then deadlock can occur.) </p> <p> I have attached a patch that demonstrates a fix for the problem. The patch looks good to me and works for my application but has not been otherwise tested. </p> <p> My application (based on the GNU Radio trunk code - <a class="ext-link" href="http://gnuradio.org/trac"><span class="icon">​</span>http://gnuradio.org/trac</a>) is large and not easily simplified, but I think that the potential for losing the thread::interrupt notification is apparent in the code. I would be happy to test proposed fixes on my application; creating a simple example to demonstrate the problem would be more difficult for me (I don't have experience programming with boost), but I will work on it if needed. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2330 Trac 1.4.3 Don Ward <don2387ward@…> Tue, 16 Sep 2008 14:16:04 GMT attachment set https://svn.boost.org/trac10/ticket/2330 https://svn.boost.org/trac10/ticket/2330 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">thread-interrupt.patch</span> </li> </ul> <p> patch for thread::interrupt race condition </p> Ticket cfspc Thu, 09 Apr 2009 18:15:16 GMT version changed https://svn.boost.org/trac10/ticket/2330#comment:1 https://svn.boost.org/trac10/ticket/2330#comment:1 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.36.0</span> → <span class="trac-field-new">Boost 1.37.0</span> </li> </ul> <p> I have observed the same behavior in Linux on Boost 1.37.0 using gcc 4.1.2. </p> Ticket david.rusek@… Tue, 05 May 2009 03:29:55 GMT version changed https://svn.boost.org/trac10/ticket/2330#comment:2 https://svn.boost.org/trac10/ticket/2330#comment:2 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.37.0</span> → <span class="trac-field-new">Boost 1.38.0</span> </li> </ul> <p> I am seeing this behavior in linux using Boost 1.38 </p> Ticket Paul Pogonyshev <pogonyshev@…> Tue, 08 Dec 2009 00:56:31 GMT severity changed https://svn.boost.org/trac10/ticket/2330#comment:3 https://svn.boost.org/trac10/ticket/2330#comment:3 <ul> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Showstopper</span> </li> </ul> <p> Observed on Linux with Boost 1.41. How can this bug be not fixed still?! This is a real showstopper that can randomly lock down any program. </p> <p> See also <a class="ext-link" href="http://groups.google.com/group/boost-list/browse_thread/thread/30e4efca95cc064c/6ea3c58c188f7421?lnk=raot"><span class="icon">​</span>http://groups.google.com/group/boost-list/browse_thread/thread/30e4efca95cc064c/6ea3c58c188f7421?lnk=raot</a> </p> Ticket Paul Pogonyshev <pogonyshev@…> Thu, 10 Dec 2009 00:57:06 GMT version changed; milestone deleted https://svn.boost.org/trac10/ticket/2330#comment:4 https://svn.boost.org/trac10/ticket/2330#comment:4 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.38.0</span> → <span class="trac-field-new">Boost 1.41.0</span> </li> <li><strong>milestone</strong> <span class="trac-field-deleted">Boost 1.37.0</span> </li> </ul> Ticket anonymous Mon, 07 Jun 2010 08:50:01 GMT type changed https://svn.boost.org/trac10/ticket/2330#comment:5 https://svn.boost.org/trac10/ticket/2330#comment:5 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Patches</span> </li> </ul> Ticket Anthony Williams Thu, 28 Oct 2010 10:26:28 GMT status changed https://svn.boost.org/trac10/ticket/2330#comment:6 https://svn.boost.org/trac10/ticket/2330#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Anthony Williams Thu, 28 Oct 2010 14:19:18 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2330#comment:7 https://svn.boost.org/trac10/ticket/2330#comment:7 <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> <p> Fixed on trunk revision 66228 </p> Ticket anonymous Mon, 01 Nov 2010 13:11:14 GMT <link>https://svn.boost.org/trac10/ticket/2330#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2330#comment:8</guid> <description> <p> see <a class="ext-link" href="http://permalink.gmane.org/gmane.comp.lib.boost.devel/210220"><span class="icon">​</span>http://permalink.gmane.org/gmane.comp.lib.boost.devel/210220</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 23 Aug 2016 09:16:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2330#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2330#comment:9</guid> <description> <p> In our projects, a similar case occured with boost 1.55. We create a new thread to do something every 10 seconds. If the last thread dosn't finish, interrupt it before creation. After some time, we found that the creator dosn't run any more after call interrupt. Restart the process, it run well again. It is a pity that we don't dump the stack for some reason, so can't determine what occured on earth. Does this bug be repaired completely? Or it appears again in boost 1.55? </p> </description> <category>Ticket</category> </item> <item> <author>clblacksmith@…</author> <pubDate>Tue, 23 Aug 2016 09:20:09 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2330#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2330#comment:10</guid> <description> <p> In our projects, a similar case occured with boost 1.55. We create a new thread to do something every 10 seconds. If the last thread dosn't finish, interrupt it before creation. After some time, we found that the creator dosn't run any more after call interrupt. Restart the process, it run well again. It is a pity that we don't dump the stack for some reason, so can't determine what occured on earth. Does this bug be repaired completely? Or it appears again in boost 1.55? </p> </description> <category>Ticket</category> </item> </channel> </rss>