Boost C++ Libraries: Ticket #11914: abort is called while boost::filesystem::copy tries to throw and exception https://svn.boost.org/trac10/ticket/11914 <p> Im" using boost 1.60 with Visual Studio 2015 WIN64. Compiled boost simply by running: </p> <blockquote> <p> bootstrap.bat tools/build/b2 toolset=msvc-14.0 --build-type=minimal --link=static stage </p> </blockquote> <p> Now, I get a specific situation where abort is called while boost::filesystem::copy tries to throw an exception. Note that other boost::filesystem functions successfully throws. </p> <p> This code: </p> <pre class="wiki">#include &lt;boost/filesystem.hpp&gt; #include &lt;boost/filesystem/operations.hpp&gt; #include &lt;iostream&gt; int main( int argc, char* argv[] ) { // Stepping to folder: try { boost::filesystem::current_path("B:/dev/msvc2015/vobs_bci/public/tst/base/cppunit/utlfile"); std::cout &lt;&lt; "Worked" &lt;&lt; std::endl; // works OK } catch (...) { } // test throwing upon copy_directory because dource folder does not exist: try { boost::filesystem::copy_directory("s", "b"); } catch (...) { std::cout &lt;&lt; "Caught" &lt;&lt; std::endl; // works OK } // test throwing upon copy because target file already exists: try { boost::filesystem::copy("./test.h", "./copied.cpp"); // works boost::filesystem::copy("./test.h", "./copied.cpp"); // should throw and be caught } catch (...) { std::cout &lt;&lt; "Caught" &lt;&lt; std::endl; // never reached... } std::cout &lt;&lt; "Done" &lt;&lt; std::endl; return 0; } </pre><p> Outputs: </p> <pre class="wiki">Worked Caught </pre><p> And then aborts... </p> <p> Posted on SO first: <a class="ext-link" href="http://stackoverflow.com/questions/34793451/why-is-boostfilesystem-aborting-instead-of-throwing-an-exception"><span class="icon">​</span>http://stackoverflow.com/questions/34793451/why-is-boostfilesystem-aborting-instead-of-throwing-an-exception</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11914 Trac 1.4.3 jpo38 <jean.porcherot@…> Fri, 15 Jan 2016 09:19:53 GMT <link>https://svn.boost.org/trac10/ticket/11914#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11914#comment:1</guid> <description> <p> Problem is that code ends up throwing an exception from a noexpt function! </p> <p> The version of copy_directory the code posted reaches does not have BOOST_NOEXCEPT flag (line 532 of boost.org/doc/libs/1_60_0/boost/filesystem/operations.hpp), while the version of copy_file reached has it (line 548). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 21 Jan 2016 22:43:12 GMT</pubDate> <title>component changed; owner set https://svn.boost.org/trac10/ticket/11914#comment:2 https://svn.boost.org/trac10/ticket/11914#comment:2 <ul> <li><strong>owner</strong> set to <span class="trac-author">Beman Dawes</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">filesystem</span> </li> </ul> Ticket jpo38 <jean.porcherot@…> Mon, 04 Dec 2017 16:37:21 GMT <link>https://svn.boost.org/trac10/ticket/11914#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11914#comment:3</guid> <description> <p> I am unable to reproduce this bug with boost 1.65.1 </p> </description> <category>Ticket</category> </item> <item> <author>jpo38 <jean.porcherot@…></author> <pubDate>Mon, 04 Dec 2017 17:00:59 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11914#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11914#comment:4</guid> <description> <p> My mistake, I can still reproduce this with 1.65.1. The problem was not fixed yet </p> </description> <category>Ticket</category> </item> <item> <author>jpo38 <jean.porcherot@…></author> <pubDate>Mon, 04 Dec 2017 17:01:14 GMT</pubDate> <title>version changed https://svn.boost.org/trac10/ticket/11914#comment:5 https://svn.boost.org/trac10/ticket/11914#comment:5 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.60.0</span> → <span class="trac-field-new">Boost 1.65.0</span> </li> </ul> Ticket jpo38 <jean.porcherot@…> Mon, 04 Dec 2017 17:01:25 GMT cc set https://svn.boost.org/trac10/ticket/11914#comment:6 https://svn.boost.org/trac10/ticket/11914#comment:6 <ul> <li><strong>cc</strong> <span class="trac-author">jean.porcherot@…</span> added </li> </ul> Ticket anonymous Thu, 05 Apr 2018 07:16:11 GMT <link>https://svn.boost.org/trac10/ticket/11914#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11914#comment:7</guid> <description> <p> Why isn't this set to showstopper? How is the current behavior in any way acceptable? </p> </description> <category>Ticket</category> </item> <item> <author>sudhanshu.gupta05@…</author> <pubDate>Wed, 25 Apr 2018 08:25:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11914#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11914#comment:8</guid> <description> <p> The problem here is that implementation of boost::filesystem::detail::copy() (operations.cpp:978) incorrectly goes through the nothrow version of boost::filesystem::copy_file (also copy_directories and copy_symlink). Hence when the exception is eventually thrown there is no handler and terminate is called. </p> </description> <category>Ticket</category> </item> <item> <author>sudhanshu.gupta05@…</author> <pubDate>Wed, 25 Apr 2018 09:13:14 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/11914 https://svn.boost.org/trac10/ticket/11914 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">copy_exceptions.patch</span> </li> </ul> <p> Patch contains the fix for the issue. </p> Ticket