Boost C++ Libraries: Ticket #5859: win32 shared_mutex constructor leaks on exceptions https://svn.boost.org/trac10/ticket/5859 <p> shared_mutex's contructor contains three calls to create_anonymous_semaphore(), each of which can throw. If one of these throws, the unprotected handles of the previous ones will leak. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5859 Trac 1.4.3 viboes Fri, 02 Dec 2011 22:24:08 GMT owner, status changed; cc set https://svn.boost.org/trac10/ticket/5859#comment:1 https://svn.boost.org/trac10/ticket/5859#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">viboes</span> added </li> <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> Thanks for this report. I will try to solve it soon. </p> Ticket viboes Sun, 04 Dec 2011 15:38:10 GMT <link>https://svn.boost.org/trac10/ticket/5859#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5859#comment:2</guid> <description> <p> In order to avoid a chained try-catch a no_throw create_anonymous_semaphore_nothrow function can be used like in </p> <pre class="wiki"> if (!semaphores[exclusive_sem]) { detail::win32::release_semaphore(semaphores[unlock_sem],LONG_MAX); boost::throw_exception(thread_resource_error()); } upgrade_sem=detail::win32::create_anonymous_semaphore_nothrow(0,LONG_MAX); if (!upgrade_sem) { detail::win32::release_semaphore(semaphores[unlock_sem],LONG_MAX); detail::win32::release_semaphore(semaphores[exclusive_sem],LONG_MAX); boost::throw_exception(thread_resource_error()); } </pre><p> While this is not too elegant it solves the issue. A RAI handle would be also appreciated. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 04 Dec 2011 23:07:16 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/5859#comment:3 https://svn.boost.org/trac10/ticket/5859#comment:3 <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> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.49.0</span> </li> </ul> <p> Committed in trunk At revision: <a class="changeset" href="https://svn.boost.org/trac10/changeset/75806" title="Thread: #5859 win32 shared_mutex constructor leaks on exceptions">[75806]</a> </p> Ticket viboes Sun, 04 Dec 2011 23:17:45 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/5859#comment:4 https://svn.boost.org/trac10/ticket/5859#comment:4 <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> Let close the ticket when merged to release </p> Ticket viboes Sat, 07 Jan 2012 22:49:57 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5859#comment:5 https://svn.boost.org/trac10/ticket/5859#comment:5 <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> <p> Committed in release at <a class="changeset" href="https://svn.boost.org/trac10/changeset/76291" title="Thread fixed Bugs: * [@http://svn.boost.org/trac/boost/ticket/2309 ...">[76291]</a> </p> Ticket