Opened 9 years ago

Closed 8 years ago

#8930 closed Bugs (fixed)

boost::path::root_directory() throws locale::facet::_S_create_c_locale name not valid

Reported by: Yaohan Chen <yaohan.chen@…> Owned by: Beman Dawes
Milestone: Boost 1.57.0 Component: filesystem
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

On Arch Linux with boost 1.54.0, I'm getting locale::facet::_S_create_c_locale name not valid when calling boost::path::root_directory() while LANG is set to a locale which is unlisted in locale -a.

boost_file_system_test.cpp:

#include <boost/filesystem.hpp>
int main() {
  boost::filesystem::path("/abc").root_directory();
}

Compiling, running and backtrace:

$ g++ -std=c++0x -I/usr/include -lboost_filesystem -lboost_system -o boost_filesystem_test boost_file_system_test.cpp

$ LANG=foo gdb boost_file_system_test
...
terminate called after throwing an instance of 'std::runtime_error'
  what():  locale::facet::_S_create_c_locale name not valid

Program received signal SIGABRT, Aborted.
0xb7fdd424 in __kernel_vsyscall ()
(gdb) bt
#0  0xb7fdd424 in __kernel_vsyscall ()
#1  0xb7cbf256 in raise () from /usr/lib/libc.so.6
#2  0xb7cc09e3 in abort () from /usr/lib/libc.so.6
#3  0xb7eeb615 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
#4  0xb7ee9283 in ?? () from /usr/lib/libstdc++.so.6
#5  0xb7ee92bf in std::terminate() () from /usr/lib/libstdc++.so.6
#6  0xb7ee951e in __cxa_throw () from /usr/lib/libstdc++.so.6
#7  0xb7f41842 in std::__throw_runtime_error(char const*) () from /usr/lib/libstdc++.so.6
#8  0xb7f08138 in std::locale::facet::_S_create_c_locale(__locale_struct*&, char const*, __locale_struct*) () from /usr/lib/libstdc++.so.6
#9  0xb7efc759 in std::locale::_Impl::_Impl(char const*, unsigned int) ()
   from /usr/lib/libstdc++.so.6
#10 0xb7efd95a in std::locale::locale(char const*) () from /usr/lib/libstdc++.so.6
#11 0xb7f98e67 in boost::filesystem::path::codecvt() ()
   from /usr/lib/libboost_filesystem.so.1.54.0
#12 0xb7f9ab4d in boost::filesystem::path::root_directory() const ()
   from /usr/lib/libboost_filesystem.so.1.54.0
#13 0x08048ec7 in main ()

Change History (6)

comment:1 by Yaohan Chen <yaohan.chen@…>, 9 years ago

Component: Nonefilesystem
Owner: set to Beman Dawes

comment:2 by viboes, 9 years ago

Is this related to #8352 Boost-filesystem std::runtime_error: locale::facet::_S_create_c_locale name not valid failure on OpenBSD?

comment:3 by Arseniy Ankudinov <afalin@…>, 8 years ago

Seems to be related to this on FreeBSD with LC_ALL!=C, boost-1_55_0

test.cpp:

#include <boost/filesystem.hpp>
int main() {
  const char *c = "/tmp/file";
  boost::filesystem::path path(c,c+4);
  return 0;
}

Backtrace:

#0  0x0000000801073a0c in kill () from /lib/libc.so.7
#1  0x000000080107263b in abort () from /lib/libc.so.7
#2  0x00000008012d0ea4 in __gnu_cxx::__verbose_terminate_handler () from /usr/lib/libsupc++.so.1
#3  0x00000008012d53a3 in std::set_unexpected () from /usr/lib/libsupc++.so.1
#4  0x00000008012d53e3 in std::terminate () from /usr/lib/libsupc++.so.1
#5  0x00000008012d534a in __cxa_throw () from /usr/lib/libsupc++.so.1
#6  0x00000008008fb8e2 in std::__throw_runtime_error () from /usr/lib/libstdc++.so.6
#7  0x00000008008fa96d in std::locale::facet::_S_create_c_locale () from /usr/lib/libstdc++.so.6
#8  0x0000000800882fdc in std::locale::_Impl::_Impl () from /usr/lib/libstdc++.so.6
#9  0x0000000800884ce9 in std::locale::locale () from /usr/lib/libstdc++.so.6
#10 0x00000000004061cc in boost::filesystem::path::codecvt () at libs/filesystem/src/path.cpp:911
#11 0x0000000000402d3a in boost::filesystem::path::path<char const*> (this=0x7fffffffdb58, begin=0x408d20 "/tmp/file", end=0x408d24 "/file")
    at path.hpp:167
#12 0x0000000000402bf5 in boost::filesystem::path::path<char const*> (this=0x7fffffffdb58, begin=0x408d20 "/tmp/file", end=0x408d24 "/file")
    at path.hpp:169
#13 0x0000000000402965 in main () at test.cpp:4

comment:4 by Beman Dawes, 8 years ago

Status: newassigned

Just to be sure, does this also fail:

#include <boost/filesystem.hpp>

int main() {

boost::filesystem::path path("/tmp");

return 0;

}

Thanks,

--Beman

Last edited 8 years ago by Beman Dawes (previous) (diff)

comment:5 by Arseniy Ankudinov <afalin@…>, 8 years ago

No, this case passed successful on the same system.

comment:6 by Beman Dawes, 8 years ago

Milestone: To Be DeterminedBoost 1.57.0
Resolution: fixed
Status: assignedclosed

Fixed for 1.57. Note that the fix was not in 1.57 beta 1, but should be in the final release.

Thanks,

--Beman

Note: See TracTickets for help on using tickets.