Boost C++ Libraries: Ticket #5900: Access violation in boost filesystem 3 directory iterator https://svn.boost.org/trac10/ticket/5900 <p> Whenever dir_itr_increment() reports an error (e.g. because an error code was returned by <a class="missing wiki">FindNextFile</a>() on WIN32), directory_iterator_increment() will crash with an access violation when trying to throw a filesystem error. </p> <p> The access violation is caused by an attempt to read the parent path string from it.m_imp immediately after calling it.m_imp.reset(). </p> <p> Please find a patch against boost 1.47.0 attached to this ticket. It fixes the issue without any side-effects by storing the parent path locally before calling it.m_imp.reset(). </p> <p> The issue is hard to reproduce as essentially a defective file-system is required to see its effect. However, I think it should be sufficiently clear from the patch what's going on. I ran across this when trying to read from an optical disc with a defective UDF file-system. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5900 Trac 1.4.3 Andreas Eckleder <a.eckleder@…> Wed, 14 Sep 2011 11:55:54 GMT attachment set https://svn.boost.org/trac10/ticket/5900 https://svn.boost.org/trac10/ticket/5900 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">directory_iterator.patch</span> </li> </ul> <p> Patch fixing a potential access violation when trying to read defective directories / directories for which windows replies with an error code in <a class="missing wiki">FindNextFile</a>(). </p> Ticket anonymous Fri, 06 Jan 2012 01:59:51 GMT <link>https://svn.boost.org/trac10/ticket/5900#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5900#comment:1</guid> <description> <p> We ran into the same problem on OSX, when a directory was deleted while we were in the middle of iterating over it. Note that if you don't want to or can't change the source to Boost as per the patch above, simply passing in an error_code to directory_iterator::increment() will circumvent the bug, since the bad dereference is buried in the exception creation. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 18 Jan 2012 20:43:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5900#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5900#comment:2</guid> <description> <p> I was wrong in my previous comment stating that there was a work-around without changing the source to Boost. There's a second bug that stops this from working. directory_iterator_construct() does not pass the error code to "increment", so even if an error code is passed into directory_iterator_construct(), when it gets into directory_iterator_increment() the error code will be lost and the exception will trigger. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Beman Dawes</dc:creator> <pubDate>Wed, 18 Jan 2012 22:15:08 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/5900#comment:3 https://svn.boost.org/trac10/ticket/5900#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> I'm working Filesystem bugs right now. I'll work this one tomorrow or the next day. </p> <p> Thanks, </p> <p> --Beman </p> Ticket Beman Dawes Sun, 22 Jan 2012 02:21:20 GMT status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/5900#comment:4 https://svn.boost.org/trac10/ticket/5900#comment:4 <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> Both the original bug and the bug reported in comment 3 have been fixed. </p> <p> Thanks for the reports and the patch! </p> <p> --Beman </p> Ticket