Boost logo

Boost Users :

Subject: [Boost-users] Need help with XCode - simple RegEx test app crashes on OS X (Darwin)
From: Thomas Tempelmann (tt_at_[hidden])
Date: 2008-12-19 09:38:36


I wanted to try out boost for the first time and ran into a basic problem:

The regex test app as suggested on the installation page crashes inside the
destructor of "match_results".

I wonder if the libs created by the boost installer are built in an
incompatible manner to what XCode generates from my own test code.

I could not find any troubleshooting or special instructions for using boost
with XCode, though.

Here's some more details:

I've installed boost 1.37, on two Macs (both Intel, one with 10.5.5, other
with 10.5.6), both XCode 3.1.2 (gcc 4.01). Once installed using the official
distribution, using "configure" and "make install", once using MacPorts.
Both build error-free, and similarly (only difference I could see is that
the former installs in /usr/local/ while the other in /opt/local).

I basically followed the unix install instructions from here:

http://www.boost.org/doc/libs/1_37_0/more/getting_started/unix-variants.html
#link-your-program-to-a-boost-library

Chapter 6 then suggests to test a little regex program. I created a new C++
Tool project in XCode, put the test code into main.cpp and changed only
these three build options:

HEADER_SEARCH_PATHS = /opt/local/include
LIBRARY_SEARCH_PATHS = /opt/local/lib
OTHER_LDFLAGS = -lboost_regex-mt

The app then builds fine without errors. And I can launch it, where it then
waits for input. Meaning that boost basically works.

It even performs the regex query just fine.

Only then, when it loops around, it crashes with a segmentation fault deep
inside the destructor of "boost::smatch matches".

Here's the stack trace:

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000067616c66
Crashed Thread: 0

Thread 0 Crashed:
0 libstdc++.6.dylib 0x92c57964
__gnu_debug::_Safe_iterator_base::_M_detach() + 62
1 libstdc++.6.dylib 0x92c579ce
__gnu_debug::_Safe_iterator_base::_M_attach(__gnu_debug::_Safe_sequence_base
*, bool) + 42
2 libstdc++.6.dylib 0x92c57ad4
__gnu_debug::_Safe_sequence_base::_M_detach_all() + 42
3 boost-test 0x00002c87
__gnu_debug::_Safe_sequence_base::~_Safe_sequence_base() + 23
4 boost-test 0x00002feb
__gnu_debug::_Safe_sequence<__gnu_debug_def::vector<boost::sub_match<__gnu_c
xx::__normal_iterator<char const*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > >,
std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >
> >::~_Safe_sequence() + 23
5 boost-test 0x00003449
__gnu_debug_def::vector<boost::sub_match<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>, std::allocator<char>
> > >, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char
const*, std::basic_string<char, std::char_traits<char>, std::allocator<char>
> > > > >::~vector() + 29
6 boost-test 0x000034db
boost::match_results<__gnu_cxx::__normal_iterator<char const*,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > >,
std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*,
std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >
>::~match_results() + 23
7 boost-test 0x00002809 main + 215 (main.cpp:18)
8 boost-test 0x00002052 _start + 216
9 boost-test 0x00001f79 start + 41

Any ideas what's going wrong here?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net