Opened 15 years ago

Closed 12 years ago

Last modified 12 years ago

#1701 closed Bugs (wontfix)

boost::filesystem::remove_all - segmentation fault with wpath on Linux

Reported by: Igor.Solovyov@… Owned by: Beman Dawes
Milestone: Boost 1.36.0 Component: filesystem
Version: Boost 1.34.1 Severity: Problem
Keywords: remove_all Cc:

Description

Hi,

I came across unexpectedly on the problem with boost::filesystem::remove_all and widechar-strings on the Linux and GCC.

My compilation environment:

  • Fedora7;
  • gcc version 4.1.2 20070925 (Red Hat 4.1.2-27);
  • boost 1.34.1.

The following test program leads segmentation fault at the line marked with "Boom!!!" comment.

#include <iostream>
#include <boost/filesystem.hpp>

int main( int argc, char const * argv[] )
{
    namespace fs = boost::filesystem;

    // This doesn't work
    fs::wpath tempRoot = L"./temp1/temp2";
    fs::wpath root = L"./temp1";
    // This works.
    //fs::path tempRoot = "./temp1/temp2";
    //fs::path root = "./temp1";

    try
    {
        std::cerr << "--- boost filesystem test --- " << std::endl;
        bool bRes = fs::create_directories( tempRoot );
        std::cerr << "bRes: " << bRes << std::endl;
        if ( bRes )
        {
            unsigned long n = fs::remove_all( root ); // <- Boom!!!
            std::cerr << "n: " << n << std::endl;
        }
    }
    catch ( std::exception const & ex )
    {
        std::cerr << "Exception: " << ex.what() << std::endl;
    }

    return 0;
}

The source was compiled with following options: g++ -g boost_fs.cpp -I/usr/local/include/boost-1_34_1 -lboost_filesystem-gcc41-1_34_1 -o boost_fs.exe

Note, the problem arises if Unicode string is used.

Change History (2)

comment:1 by Beman Dawes, 12 years ago

Resolution: wontfix
Status: newclosed

Filesystem Version 3 is a much better solution for internationalization problems, so I'm closing this ticket since it applies to version 2.

Version 3 is scheduled to ship with 1.44, and is available in the trunk now.

Please give version 3 a try, and report any problems.

Thanks,

--Beman

comment:2 by anonymous, 12 years ago

Hm, I guess it's worth to make unit-test with mentioned above problem for version 3 as well...

Note: See TracTickets for help on using tickets.