2

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

I also performed the following: ./bjam install variant=debug define=_GLIBCXX_DEBUG --with-regex

I compiled the program using Codeblocks (without any errors) but when I run the program I get the following error:

$ ./CWT_PD
terminate called after throwing an instance of 'std::bad_cast'
  what():  std::bad_cast
Abort trap

When I look into the error using Console, I see the following error

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            0x00000001000d04b8 std::collate<char> const& std::use_facet<std::collate<char> >(std::locale const&) + 85 (locale_facets.tcc:117)
8   libboost_regex.dylib            0x00000001000a8794 boost::re_detail::cpp_regex_traits_base<char>::imbue(std::locale const&) + 124 (cpp_regex_traits.hpp:218)
9   libboost_regex.dylib            0x00000001000dae35 boost::re_detail::cpp_regex_traits_base<char>::cpp_regex_traits_base(std::locale const&) + 43 (cpp_regex_traits.hpp:173)
10  libboost_regex.dylib            0x00000001000dae83 boost::shared_ptr<boost::re_detail::cpp_regex_traits_implementation<char> const> boost::re_detail::create_cpp_regex_traits<char>(std::locale const&) + 30 (cpp_regex_traits.hpp:852)
11  libboost_regex.dylib            0x00000001000daeed boost::cpp_regex_traits<char>::cpp_regex_traits() + 35 (cpp_regex_traits.hpp:872)
12  libboost_regex.dylib            0x00000001000daf33 boost::regex_traits<char, boost::cpp_regex_traits<char> >::regex_traits() + 21 (regex_traits.hpp:75)
13  libboost_regex.dylib            0x00000001000daf4b boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > >::regex_traits_wrapper() + 21 (regex_traits.hpp:169)
14  libboost_regex.dylib            0x00000001000daf8d boost::re_detail::regex_data<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::regex_data() + 63 (basic_regex.hpp:212)
15  libboost_regex.dylib            0x00000001000db041 boost::re_detail::basic_regex_implementation<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::basic_regex_implementation() + 21 (basic_regex.hpp:248)
16  libboost_regex.dylib            0x00000001000a8815 boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, unsigned int) + 75 (basic_regex.hpp:698)
17  CWT_PD                          0x000000010000b9bc mzxml::Reader::read_index_offset() + 92
18  CWT_PD                          0x00000001000056cb main + 2571
19  CWT_PD                          0x0000000100001698 start + 52


Binary Images:
       0x100000000 -        0x10003dfe7 +CWT_PD ??? (???) <0C453159-591D-862F-B273-7450BCF7E4D5> /Users/dspiciarich/Desktop/B/CWT_PD_fast/bin/Release/CWT_PD
       0x10005b000 -        0x1001ecfef +libboost_regex.dylib ??? (???) <F0FCDDDF-8C65-D0CA-33D9-93D50CDE0DD7> /usr/local/lib/libboost_regex.dylib
    0x7fff5fc00000 -     0x7fff5fc3bdef  dyld 132.1 (???) <B536F2F1-9DF1-3B6C-1C2C-9075EA219A06> /usr/lib/dyld
    0x7fff81aad000 -     0x7fff81ab1ff7  libmathCommon.A.dylib 315.0.0 (compatibility 1.0.0) <95718673-FEEE-B6ED-B127-BCDBDB60D4E5> /usr/lib/system/libmathCommon.A.dylib
    0x7fff8262c000 -     0x7fff826a9fef  libstdc++.6.dylib 7.9.0 (compatibility 7.0.0) <35ECA411-2C08-FD7D-11B1-1B7A04921A5C> /usr/lib/libstdc++.6.dylib
    0x7fff83774000 -     0x7fff83934fef  libSystem.B.dylib 125.2.0 (compatibility 1.0.0) <95E02DD0-ADEA-745B-E7FA-ABA064E4658C> /usr/lib/libSystem.B.dylib
    0x7fffffe00000 -     0x7fffffe01fff  libSystem.B.dylib ??? (???) <95E02DD0-ADEA-745B-E7FA-ABA064E4658C> /usr/lib/libSystem.B.dylib

I would be so appreciative of any help anyone could provide.

Thank you, David

David
  • 41
  • 3
  • And which statement in your program is causing the crash? That might be useful information... – Tim Pietzcker Sep 22 '10 at 06:18
  • Still trying to parse out where it is crashing but the same code executes on a Ubuntu machine and works well but crashes on a Mac. Could this be a GCC problem or how I have set a global variable? – David Sep 23 '10 at 19:32
  • In my cast it throws the exception when it parses the regex. Also I'm on Ubuntu 14.10... – Alexis Wilke Oct 17 '14 at 01:36
  • There is this post too: http://stackoverflow.com/questions/12530406/is-gcc4-7-buggy-about-regular-expressions – Alexis Wilke Oct 17 '14 at 02:16

1 Answers1

1

this seems very old but I just had the same exact issue when I built a program that is linked statically against libstdc++ and boost on Ubuntu 18.04, tried to run in it on CentOS 7, I believe issues like that can happen due to the different c++ runtimes on operating systems.

As far as I understood from debugging and reading about related issues, the crash happens when symbols from the c++ runtime already present on CentOS get called instead of the ones that are inside my program.

The solution that worked was hiding the symbols of static libraries used in my program using

-Wl,--exclude-libs,ALL gcc linker flag, of course this can be customized if you don't want to hide all static libraries.

refs:

https://stackoverflow.com/a/35675938/3673564

How to apply -fvisibility option to symbols in static libraries?

demon36
  • 377
  • 3
  • 10