On Fri, Dec 28, 2012 at 10:14 PM, Shawn Chidester <schidester@attensity.com> wrote:
Just upgraded from boost 1.47 to 1.52 and I'm experiencing segmentation faults in boost::filesystem::path::imbue.  This is on 64-bit Ubuntu 12.04 and 12.10.  Compiling with g++-4.6

Here is a stack trace from valgrind:

==26893== Memcheck, a memory error detector
==26893== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==26893== Using Valgrind-3.9.0.SVN and LibVEX; rerun with -h for copyright info
==26893== Command: bin/example
==26893==
==26893== Invalid read of size 4
==26893==    at 0x9843970: std::locale::locale(std::locale const&) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.17)
==26893==    by 0x69FAD0F: boost::filesystem::path::imbue(std::locale const&) (path.cpp:918)
==26893==    by 0x69FAC76: boost::filesystem::path::codecvt() (path.cpp:911)
==26893==    by 0x69F8546: boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<char*>::type>, boost::filesystem::path&>::type boost::filesystem::path::operator=<char*>(char* const&) (path.hpp:202)
==26893==    by 0x69F4737: boost::filesystem::detail::current_path(boost::system::error_code*) (operations.cpp:1077)
==26893==    by 0x5AB0D2C: boost::filesystem::current_path() (operations.hpp:429)
==26893==    by 0x5AB0447: __static_initialization_and_destruction_0(int, int) (example.cpp:53)
==26893==    by 0x5AB0BB5: _GLOBAL__sub_I_example.cpp (example.cpp:1192)
==26893==    by 0x400F315: call_init.part.0 (dl-init.c:85)
==26893==    by 0x400F3EE: _dl_init (dl-init.c:52)
==26893==    by 0x40016F9: ??? (in /lib/x86_64-linux-gnu/ld-2.15.so)

The stack trace looks the same in GDB.  In case it's of any use here's what "path_locale" looks like at path.cpp:918

(gdb) frame
#1  0x00007ffff561ed10 in boost::filesystem::path::imbue (loc=...)
    at boost/libs/filesystem/src/path.cpp:918
918     std::locale temp(path_locale);

(gdb) print path_locale
$1 = {_M_impl = 0x0}

I'm guessing the crash has to do with path_locale being uninitialized, but I don't know what to do about it (if that is indeed the problem).

If anyone can provide some insight (or better yet, a solution) I would be very grateful!

Thanks,
Shawn
 
Hi Shawn, 

the stack trace looks like this happens before reaching main() function. Hmm, the file is named example.cpp ;) Can you give us a minimal working code example that triggers this crash?

Benjamin