[Boost-bugs] [Boost C++ Libraries] #6817: Appending to an empty path segfaults...

Subject: [Boost-bugs] [Boost C++ Libraries] #6817: Appending to an empty path segfaults...
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-04-21 15:52:26


#6817: Appending to an empty path segfaults...
---------------------------------+------------------------------------------
 Reporter: sean@… | Owner: bemandawes
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: filesystem
  Version: Boost 1.49.0 | Severity: Regression
 Keywords: filesystem append |
---------------------------------+------------------------------------------
 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.

 {{{
 #!div style="font-size: 100%"
 Code highlighting:
   {{{#!c++
 /* Compile instructions:
 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
 ./test_path
 */

 #include "boost/filesystem.hpp"

 const std::string default_path = "foo";

 int
 main(int argc, char* argv[]) {
   boost::filesystem::path init_path;
   init_path /= default_path;
   std::cout << "Path: " << init_path << std::endl;
   return 0;
 }

 }}}
 }}}

 {{{
 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<std::__1::basic_string<char,
 std::__1::char_traits<char>, std::__1::allocator<char> > >
 (this=0x7fff5fbff4e0, source=@0x100002288, cvt=<value temporarily
 unavailable, due to optimizations>) at path.hpp:679
 #2 0x0000000100000f6e in main (argc=1606415584, argv=0x100002288) at
 test_path.cpp:249
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6817>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC