Boost C++ Libraries: Ticket #4671: std::bad_cast crash seems to be linked to boost_regex https://svn.boost.org/trac10/ticket/4671 <p> I've gotten the exact same code compiled on Ubuntu and am now trying to get my program working on a MacOS 10.6.4. I installed boost 1.4.4 as root using ./bootstrap.sh and then ./bjam </p> <p> I also performed the following: ./bjam install variant=debug define=_GLIBCXX_DEBUG --with-regex </p> <p> I compiled the program using Codeblocks (without any errors) but when I run the program I get the following error: </p> <pre class="wiki"> </pre><pre class="wiki">./graph_search terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast Abort trap </pre><p> When I look into the error using Console, I see the following error </p> <pre class="wiki">Thread 0 Crashed: Dispatch queue: com.apple.main-thread 0 libSystem.B.dylib 0x00007fff837c33d6 __kill + 10 1 libSystem.B.dylib 0x00007fff83863972 abort + 83 2 libstdc++.6.dylib 0x00007fff826785d2 __tcf_0 + 0 3 libstdc++.6.dylib 0x00007fff82676ae1 __cxxabiv1::__terminate(void (*)()) + 11 4 libstdc++.6.dylib 0x00007fff82676b16 __cxxabiv1::__unexpected(void (*)()) + 0 5 libstdc++.6.dylib 0x00007fff82676bfc __gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*) + 0 6 libstdc++.6.dylib 0x00007fff8263293f std::__throw_bad_alloc() + 0 7 libboost_regex.dylib 0x00000001000c34b8 std::collate&lt;char&gt; const&amp; std::use_facet&lt;std::collate&lt;char&gt; &gt;(std::locale const&amp;) + 85 (locale_facets.tcc:117) 8 libboost_regex.dylib 0x000000010009b794 boost::re_detail::cpp_regex_traits_base&lt;char&gt;::imbue(std::locale const&amp;) + 124 (cpp_regex_traits.hpp:218) 9 libboost_regex.dylib 0x00000001000cde35 boost::re_detail::cpp_regex_traits_base&lt;char&gt;::cpp_regex_traits_base(std::locale const&amp;) + 43 (cpp_regex_traits.hpp:173) 10 libboost_regex.dylib 0x00000001000cde83 boost::shared_ptr&lt;boost::re_detail::cpp_regex_traits_implementation&lt;char&gt; const&gt; boost::re_detail::create_cpp_regex_traits&lt;char&gt;(std::locale const&amp;) + 30 (cpp_regex_traits.hpp:852) 11 libboost_regex.dylib 0x00000001000cdeed boost::cpp_regex_traits&lt;char&gt;::cpp_regex_traits() + 35 (cpp_regex_traits.hpp:872) 12 libboost_regex.dylib 0x00000001000cdf33 boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt;::regex_traits() + 21 (regex_traits.hpp:75) 13 libboost_regex.dylib 0x00000001000cdf4b boost::regex_traits_wrapper&lt;boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::regex_traits_wrapper() + 21 (regex_traits.hpp:169) 14 libboost_regex.dylib 0x00000001000cdf8d boost::re_detail::regex_data&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::regex_data() + 63 (basic_regex.hpp:212) 15 libboost_regex.dylib 0x00000001000ce041 boost::re_detail::basic_regex_implementation&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::basic_regex_implementation() + 21 (basic_regex.hpp:248) 16 libboost_regex.dylib 0x000000010009b815 boost::basic_regex&lt;char, boost::regex_traits&lt;char, boost::cpp_regex_traits&lt;char&gt; &gt; &gt;::do_assign(char const*, char const*, unsigned int) + 75 (basic_regex.hpp:698) 17 graph_search 0x00000001000055e5 main + 773 18 graph_search 0x0000000100001048 start + 52 Thread 0 crashed with X86 Thread State (64-bit): rax: 0x0000000000000000 rbx: 0x00007fff7066e2d8 rcx: 0x00007fff5fbfdc18 rdx: 0x0000000000000000 rdi: 0x000000000000a367 rsi: 0x0000000000000006 rbp: 0x00007fff5fbfdc30 rsp: 0x00007fff5fbfdc18 r8: 0x0000000000000000 r9: 0x0000000100600460 r10: 0x00007fff837bf412 r11: 0x0000000000000202 r12: 0x00007fff8267b530 r13: 0x0000000100600420 r14: 0x0000000000000000 r15: 0x0000000000000000 rip: 0x00007fff837c33d6 rfl: 0x0000000000000202 cr2: 0x00007fff7067f058 </pre><p> I would be so appreciative of any help anyone could provide. </p> <p> Thank you, Spinach </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4671 Trac 1.4.3 Marshall Clow Mon, 15 Nov 2010 22:22:56 GMT component changed; owner set https://svn.boost.org/trac10/ticket/4671#comment:1 https://svn.boost.org/trac10/ticket/4671#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">John Maddock</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">regex</span> </li> </ul> Ticket anonymous Tue, 16 Nov 2010 09:09:40 GMT <link>https://svn.boost.org/trac10/ticket/4671#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4671#comment:2</guid> <description> <p> This is a problem with the locale you are using - for whatever reason it doesn't contain a std::collate&lt;char&gt; facet - as it's required to do so by the standard. </p> <p> You could try and reproduce with: </p> <pre class="wiki">std::locale l; std::use_facet&lt;std::collate&lt;char&gt; &gt;(l); </pre><p> and see if that also throws. </p> <p> If it does, I'm not sure what the cause/solution is - it certainly should be reported to the libstdc++ developers if it's reproducable. I'm also not sure why we don't see this problem on any of our MacOS test machines. As a workaround you could try defining BOOST_REGEX_USE_C_LOCALE in boost/regex/user.hpp so the library doesn't use the C++ locale at all (and rebuild obviously). </p> <p> One final check, I note that you're building the library with _GLIBCXX_DEBUG defined, I assume that your app is also built with that defined? If not it will crash for sure as in general you can't mix object files with and without that define. </p> <p> HTH, John. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Thu, 06 Jan 2011 11:32:28 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4671#comment:3 https://svn.boost.org/trac10/ticket/4671#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">worksforme</span> </li> </ul> Ticket