Opened 9 years ago

Closed 8 years ago

#9054 closed Bugs (fixed)

filesystem::path::codecvt() segfault pre-main with static filesystem

Reported by: lukester_null@… Owned by: Beman Dawes
Milestone: Boost 1.56.0 Component: filesystem
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

Hi

Should boost::filesystem::path::codecvt() work pre-main when using static builds of the library? I'm getting a NULL std::locale::_M_impl in std::locale::locale(const std::locale &).

Simple test case:

#include "boost/filesystem.hpp"

static const boost::filesystem::path::codecvt_type &dummy =
  boost::filesystem::path::codecvt();

int main()
{
    return 0;
}

Compiled with:

g++ Main.cpp -o Test -lboost_filesystem -lboost_system -L/path/to/static/libs/only -I/path/to/boost -g

Yields:

(gdb) bt
#0  __atomic_add_dispatch (__val=1, __mem=0x0)
    at /usr/src/debug/gcc-4.8.1-20130603/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/ext/atomicity.h:96
#1  _M_add_reference (this=0x0)
    at /usr/src/debug/gcc-4.8.1-20130603/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/locale_classes.h:510
#2  std::locale::locale (
    this=0x609630 <boost::filesystem::path::codecvt()::posix_lazy_initialization>, __other=...)
    at ../../../../../libstdc++-v3/src/c++98/locale.cc:80
#3  0x00000000004023dc in boost::filesystem::path::codecvt() ()
#4  0x0000000000401a2f in __static_initialization_and_destruction_0 (__initialize_p=1, 
    __priority=65535) at Main.cpp:3
#5  0x0000000000401a4b in _GLOBAL__sub_I_main () at Main.cpp:8
#6  0x000000000040787d in __libc_csu_init ()
#7  0x0000003f09a21b05 in __libc_start_main (main=0x4019c0 <main()>, argc=1, ubp_av=0x7fffffffd6d8, 
    init=0x407830 <__libc_csu_init>, fini=<optimized out>, rtld_fini=<optimized out>, 
    stack_end=0x7fffffffd6c8) at libc-start.c:217
#8  0x00000000004018fd in _start ()

Move the dummy into main() and all is well.

(The actual code isn't trying to call codecvt directly; it's creating a path from a G++ vstring.)

Thanks

Luke Elliott.

Change History (4)

comment:1 by anonymous, 9 years ago

Sorry, forgot to say (though it's somewhat implicit from the callstack) - Fedora 19, GCC 4.8.

comment:2 by anonymous, 8 years ago

What with this bug? It can not be fixed?

in reply to:  2 comment:3 by anonymous, 8 years ago

Replying to anonymous:

What with this bug? It can not be fixed?

Problem may occure while using openvz conteiner

comment:4 by Beman Dawes, 8 years ago

Milestone: To Be DeterminedBoost 1.56.0
Resolution: fixed
Status: newclosed

Fixed 2c0d73967d70409a58a6b700210a2f474926ecfd

Test program supplied was run on Linux/gcc against:

1.54.0 (failed) 1.55.0 (failed) 1.56.0 RC2 (passed)

Thanks,

--Beman

Note: See TracTickets for help on using tickets.