<div dir="ltr">Problems is static constructor of<div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,0,128)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,0,128)">locale</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">id</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">ctype</span><span style="color:rgb(0,0,0)"><</span><span style="color:rgb(128,128,0)">char</span><span style="color:rgb(0,0,0)">>::</span><span style="color:rgb(128,0,0)">id</span><span style="color:rgb(0,0,0)">;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">is called after</pre><pre style="margin-top:0px;margin-bottom:0px"><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">install</span><span style="color:rgb(0,0,0)">(&</span><span style="color:rgb(0,0,0)">make</span><span style="color:rgb(0,0,0)"><</span><span style="color:rgb(0,0,128)">_VSTD</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">ctype</span><span style="color:rgb(0,0,0)"><</span><span style="color:rgb(128,128,0)">char</span><span style="color:rgb(0,0,0)">></span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">>((</span><span style="color:rgb(128,0,128)">ctype_base</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">mask</span><span style="color:rgb(0,0,0)">*)</span><span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">false</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">1u</span><span style="color:rgb(0,0,0)">));</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px"><p style="margin:0px">~"#0 id (this=<optimized out>) at /home/vv/kom/libcxx/include/__locale:131\n"</p>
<p style="margin:0px">>~"#1 __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at /home/vv/kom/libcxx/src/locale.cpp:879\n"</p><p style="margin:0px">>~"#2 0xb7f350bd in _GLOBAL__sub_I_locale.cpp(void) () at /home/vv/kom/libcxx/src/locale.cpp:6144\n"</p>
<p style="margin:0px">>~"#3 0x45a7b696 in call_init.part.0 () from /lib/ld-linux.so.2\n"</p><p style="margin:0px">>~"#4 0x45a7b75b in _dl_init_internal () from /lib/ld-linux.so.2\n"</p><p style="margin:0px">
>~"#5 0x45a6d18f in _dl_start_user () from /lib/ld-linux.so.2\n"</p>
<p style="margin:0px"><br></p><p style="margin:0px">I use Makefile</p><p style="margin:0px"><br></p><p style="margin:0px">LIBCXX_INCLUDE = $(HOME)/kom/libcxx/include/
LIBCXX_LIB = $(HOME)/kom/libcxx-build/lib/
LIBCXXABI_LIB = $(HOME)/kom/libcxxabi/lib/
all:
clang++ -g -O0 -fno-inline -std=c++11 -stdlib=libc++ -I$(LIBCXX_INCLUDE) main.cpp -L$(LIBCXX_LIB) -Wl,-rpath $(LIBCXX_LIB) -L$(LIBCXXABI_LIB) -Wl,-rpath $(LIBCXXABI_LIB) -lc++abi -pthread
</p><div><br></div><div>and clang version clang version 3.3</div></pre></pre></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 19, 2013 at 6:32 PM, Howard Hinnant <span dir="ltr"><<a href="mailto:hhinnant@apple.com" target="_blank">hhinnant@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Aug 19, 2013, at 11:10 AM, toki loki <<a href="mailto:tokiloki7@gmail.com">tokiloki7@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> Program<br>
><br>
> #include <locale><br>
> int main(int argc, char* argv[]) {<br>
> std::locale loc;<br>
> std::use_facet<std::ctype<char>>(loc);<br>
> return EXIT_SUCCESS;<br>
> }<br>
><br>
> Crashes with latest libc++ and libc++abi on Linux with backtrace<br>
><br>
><br>
> (gdb) bt<br>
> #0 0xb7fff424 in __kernel_vsyscall ()<br>
> #1 0x45abdbaf in raise () from /lib/libc.so.6<br>
> #2 0x45abf503 in abort () from /lib/libc.so.6<br>
> #3 0xb7fbf43c in abort_message (format=0xb7ff8264 "terminating with %s exception of type %s: %s") at ../src/abort_message.cpp:47<br>
> #4 0xb7fbf5f9 in default_terminate_handler () at ../src/cxa_default_handlers.cpp:63<br>
> #5 0xb7ff4f04 in std::__terminate (func=0xb7fbf4e0 <default_terminate_handler()>) at ../src/cxa_handlers.cpp:67<br>
> #6 0xb7ff44e5 in failed_throw (exception_header=<optimized out>) at ../src/cxa_exception.cpp:147<br>
> #7 __cxa_throw (thrown_object=0x804b058, tinfo=0xb7ffce50 <typeinfo for std::bad_cast>, dest=0xb7ff8170 <std::bad_cast::~bad_cast()>) at ../src/cxa_exception.cpp:242<br>
> #8 0xb7f14b82 in std::__1::locale::__imp::use_facet (<br>
> this=0xb7fb91a0 <std::__1::locale::__imp& std::__1::(anonymous namespace)::make<std::__1::locale::__imp, unsigned int>(unsigned int)::buf>, id=28)<br>
> at /home/vv/kom/libcxx/src/locale.cpp:432<br>
> #9 0xb7f15486 in std::__1::locale::use_facet (this=0xbfffeca0, x=...) at /home/vv/kom/libcxx/src/locale.cpp:574<br>
> #10 0x0804878e in main (argc=1, argv=0xbfffed54) at main.cpp:4<br>
><br>
><br>
> I have found that 'std::ctype<char>::id.__get()' is 28 for me. I have constexpr enabled.<br>
><br>
> Thanks.<br>
><br>
<br>
</div></div>The only way I know to debug this is to monitor locale::id::__init() in locale.cpp. One needs to find out who is calling it, how often, from where, and what the current value of __next_id is, and what __id_ gets set to. I do not have a linux box to debug this with.<br>
<br>
The design is that this gets called exactly 28 times with a default constructed locale and that id.__get() returns __id_-1:<br>
<br>
long<br>
locale::id::__get()<br>
{<br>
call_once(__flag_, __fake_bind(&locale::id::__init, this));<br>
return __id_ - 1;<br>
}<br>
<br>
Furthermore locale::id::__init() is a private function of locale::id and is supposed to be only called within locale::id::__get().<br>
<br>
One theory is: call_once isn't working.<br>
<span class="HOEnZb"><font color="#888888"><br>
Howard<br>
<br>
</font></span></blockquote></div><br></div>