Need help with XCode - simple RegEx test app crashes on OS X (Darwin)
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?
Thomas Tempelmann wrote:
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.
I don't really know what the issue is, but the failure is inside std::vector's destructor, my guess is this indicates maybe two different runtime libraries are in play or something? What I suggest you do is remove the reference to the regex library in your test app, and instead add the regex source (in libs/regex/src/) directly to your app. If that then builds and runs without issues then you know the problem is with binary compatibility somewhere. Then all we have to do is track down where/why ! HTH, John.
On 20.12.2008 9:58 Uhr, "John Maddock" wrote:
I don't really know what the issue is, but the failure is inside std::vector's destructor, my guess is this indicates maybe two different runtime libraries are in play or something?
Yes, could be. The thing is that the libs get built by using the std libs installed in /usr/lib and whatnot. While Xcode projects may use their own runtime libs. Not sure, though.
What I suggest you do is remove the reference to the regex library in your test app, and instead add the regex source (in libs/regex/src/) directly to your app.
Yes, that works just fine. So, maybe, until this gets resolved, you could have a note added to the unix install page for Mac Xcode users: For use with Xcode, you can skip the entire build process (as with "./configure" and "make install"), and instead just move the boost folder to a convenient central place, such as "/Library", maybe adding a symlink from the versioned boost folder to "/Library/boost", and then add "/Library/boost/boost" to the include paths in your Xcode project. And if you want to use any of the functions that would usually require precompiled libs, such as regex, simply add their "libs/<libname>/src" folder to the Xcode project. And maybe a warning that the precompiled libs generated by the default build process may crash when used with Xcode projects. Thomas
participants (2)
-
John Maddock
-
Thomas Tempelmann