Boost C++ Libraries: Ticket #6817: Appending to an empty path segfaults... https://svn.boost.org/trac10/ticket/6817 <p> path::m_append_separator_if_needed() is not checking the bounds of its inputs and segfaults. Using clang 3.1 with c++0x, this crashes every time, whereas with previous versions this was somehow insulated from this segfault. Guarding against this with calls to empty() is possible, but seems excessively burdensome to check on every append operation. </p> <div class="wikipage" style="font-size: 100%"><p> Code highlighting: </p> <div class="wiki-code"><div class="code"><pre><span class="cm">/* Compile instructions:</span> <span class="cm">clang++ -g -Wall -Wextra -pedantic -Wno-error -Wno-fatal-errors -pedantic-errors -fno-inline -std=c++0x -I/Users/sean/src/boost-prefix/include -Os -Wno-long-long -Wno-unused-parameter -Wsign-compare -stdlib=libc++ -L${HOME}/src/boost-prefix/lib -lboost_filesystem-mt -lboost_system-mt -o test_path test_path.cpp</span> <span class="cm">./test_path</span> <span class="cm">*/</span> <span class="cp">#include</span> <span class="cpf">&quot;boost/filesystem.hpp&quot;</span><span class="cp"></span> <span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">default_path</span> <span class="o">=</span> <span class="s">&quot;foo&quot;</span><span class="p">;</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span><span class="o">*</span> <span class="n">argv</span><span class="p">[])</span> <span class="p">{</span> <span class="n">boost</span><span class="o">::</span><span class="n">filesystem</span><span class="o">::</span><span class="n">path</span> <span class="n">init_path</span><span class="p">;</span> <span class="n">init_path</span> <span class="o">/=</span> <span class="n">default_path</span><span class="p">;</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;Path: &quot;</span> <span class="o">&lt;&lt;</span> <span class="n">init_path</span> <span class="o">&lt;&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span> </pre></div></div></div><pre class="wiki">Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0xffffffffffffffe8 0x000000010000db50 in boost::filesystem3::path::m_append_separator_if_needed () (gdb) bt #0 0x000000010000db50 in boost::filesystem3::path::m_append_separator_if_needed () #1 0x00000001000015dd in boost::filesystem3::path::append&lt;std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; &gt; (this=0x7fff5fbff4e0, source=@0x100002288, cvt=&lt;value temporarily unavailable, due to optimizations&gt;) at path.hpp:679 #2 0x0000000100000f6e in main (argc=1606415584, argv=0x100002288) at test_path.cpp:249 </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6817 Trac 1.4.3 Sean Chittenden <sean@…> Sat, 21 Apr 2012 17:38:11 GMT <link>https://svn.boost.org/trac10/ticket/6817#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6817#comment:1</guid> <description> <p> User error, please feel free to close. The above was compiled and linked using C++11 and stdlib=libc++, however boost was not. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Beman Dawes</dc:creator> <pubDate>Sun, 22 Apr 2012 13:55:36 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6817#comment:2 https://svn.boost.org/trac10/ticket/6817#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">invalid</span> </li> </ul> <p> Interesting. I've dropped a note to a couple of Clang and libc++ developers since it would be nice if this sort of misconfiguration error got diagnosed by the ecosystem. </p> <p> Thanks, </p> <p> --Beman </p> Ticket