Boost C++ Libraries: Ticket #2219: conditional_variable_any::any fails to release recursive_mutex when mutex has been acquired by the same thread more than one time https://svn.boost.org/trac10/ticket/2219 <p> I'm having a problem where the following code used to work in boost 1.33.0 to 1.34.1 (I have removed code for brevity). However, the code now deadlocks. It appears that the problem occurs because calling wait on a conditional_variable_any variable does not release a recursive_mutex that has been acquired by the same thread more than one time. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2219 Trac 1.4.3 brad_wade@… Mon, 18 Aug 2008 23:00:03 GMT attachment set https://svn.boost.org/trac10/ticket/2219 https://svn.boost.org/trac10/ticket/2219 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_bug.txt</span> </li> </ul> <p> Code example </p> Ticket brad_wade@… Tue, 19 Aug 2008 15:43:45 GMT <link>https://svn.boost.org/trac10/ticket/2219#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2219#comment:1</guid> <description> <p> I should note that this error occurs in Visual Studio 2005--I haven't tested other compilers or platforms. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Anthony Williams</dc:creator> <pubDate>Tue, 02 Sep 2008 10:08:02 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2219#comment:2 https://svn.boost.org/trac10/ticket/2219#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> This works as designed. condition_variably_any::wait() calls unlock on the supplied mutex. For a recursive mutex this only does one level of unlocking. </p> <p> Completely unlocking a recursive mutex is not safe in the general case. I did not realise that the old boost::condition supported it. This facility has never been tested in the boost::condition tests. I will add it to the list of breaking changes. </p> Ticket brad_wade@… Tue, 02 Sep 2008 17:34:16 GMT <link>https://svn.boost.org/trac10/ticket/2219#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2219#comment:3</guid> <description> <p> I was afraid of that. The old boost::condition would unlock the mutex however many times it had been acquired and then would restore the lock count appropriately when the wait() function completed. I was pleasantly surprised when I saw that it worked. Looks like I'll need to find a workaround... Thanks for your reply. </p> </description> <category>Ticket</category> </item> <item> <author>gpeele@…</author> <pubDate>Fri, 16 Jan 2009 19:09:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2219#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2219#comment:4</guid> <description> <p> The core issue seems to be the POSIX implementation of recursive_mutex. There is not enough information provided by POSIX to reliably save and restore the lock count, and it's not clear how much performance would have to be sacrificed to manage this state in the Boost recursive_mutex implementation. Since nothing else would require this lock state information, I assume that's why this design choice was chosen. </p> <p> As mentioned, calling lock() and unlock() multiple times inside condition_variable_any in would be unsafe, especially since this is very specific to recursive_mutex and may break the behavior for other mutex types. </p> </description> <category>Ticket</category> </item> </channel> </rss>