I've been debugging random serious crashing/hanging bugs in my project recently. I've tracked it down to what I believe is incorrect code-gen when compiling the Boost library using the Objective-C++ compiler. Specifically, here are some of the behaviors I see:
- If I enable DWARF debugging information, the debugger will exit with status 11 (segment violation?) when stepping into Boost methods. - I I enable STABS debugging, the debugger doesn't crash, but I see evidence of invalid code-gen. For example, stack and registers will get corrupted.
If I use the regular C++ compiler I don't see these problems. Unfortunately, it is a requirement that we use the Obj-C++ compiler for this project. There are places where we mix C++ and Objective-C classes and I don't see any good or easy way around this requirement.
So, before I go much further, I wanted to see if anyone has any experience in this matter and could point me toward info on Boost and Obj-C++. There are clearly bugs in the code output by Xcode/gcc.
FYI, here's some config info: - using Xcode 2.4.1 - 104.u.sdk - debug build with all optimizations turned off (-O0), using default Carbon C++ project template - PPC iMac g5 with 10.4.8
If anyone wants to test this out, feel free to compile this bit of test code with the Obj-C++ compiler and enable DWARF debugging info. The debugger exits for me when stepping into theOrderedList.begin(). It would be interesting to hear about someone else being to reproduce this problem, or if there are work-arounds to these problems.
// --------------
#include <boost/call_traits.hpp> #include <boost/multi_index_container.hpp> #include <boost/multi_index/composite_key.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/mem_fun.hpp> #include <boost/multi_index/ordered_index.hpp>
#include <list> #include <map> #include <iostream>
using namespace std; using namespace boost::multi_index;
// ***** -----------------------------------------------------------------
class TestClass { public: TestClass( int i, float f ) { mI = i; mF = f; }
int GetIntVal( void ) const { return mI; } void SetIntVal( int i ) { mI = i; }
float GetFloatVal( void ) const { return mF; } void SetFloatVal( float f ) { mF = f; } private: int mI; float mF; };
// Storage for the test objects typedef multi_index_container< TestClass, indexed_by < ordered_unique< const_mem_fun<TestClass, int, &TestClass::GetIntVal> >, ordered_non_unique< const_mem_fun<TestClass, float, &TestClass::GetFloatVal> > > > CTestClassList;
typedef nth_index<CTestClassList, 0>::type CTestListByInt; typedef nth_index<CTestClassList, 1>::type CTestListByFloat;
void TestBoost2( void ) { // Create the list CTestClassList theList;
// Insert into the list std::pair<CTestClassList::iterator, bool> Res = theList.insert( TestClass(100, 10.5) );
std::pair<CTestClassList::iterator, bool> Res1 = theList.insert( TestClass(-255, -909.93141299) );
// Get an ordered version of the list CTestListByInt& theOrderedList = theList.get<0>();
// Itereate through values in the list.
CTestClassList::iterator beginI = theOrderedList.begin(); CTestClassList::iterator endI = theOrderedList.end();
const TestClass* nextObj; for(CTestClassList::iterator Itx = beginI; Itx != endI; Itx++) { nextObj = &(*Itx); cout << "Obj with data i = " << nextObj->GetIntVal() << " and f = " << nextObj->GetFloatVal() << endl; } }
// --------------------- |