Boost logo

Boost Users :

From: Filip Konvička (filip.konvicka_at_[hidden])
Date: 2008-03-28 04:32:38


> Thanks a lot. The object_pool approach doesn't work; it causes also a segmentation fault.
> The option of explicitly allocating the object does work fine.

Make sure you use a recent compiler and Boost. I have seen pool
segfaulting on some not-so-old platforms, especially with pool_allocator
being used with nested containers. I found out that with Boost 1.34.1,
g++ 4.3.0 and MSVC 9.0 all works fine.

For example the following segfaults with g++ 4.2.2 + boost 1.32:

#include <boost/pool/pool_alloc.hpp>
#include <vector>
#include <map>

using boost::pool_allocator;
using namespace std;
int main() {
   typedef vector<double, pool_allocator<double> > v1;
   typedef map<unsigned long, v1> v2;
   v2 m;
   m.insert(make_pair(0, v1())); // SEGFAULT with g++ 4.2.2 + boost 1.32
                                 // OK with g++ 4.3.0 + boost 1.34.1
   return 0;
}

It's probably some incarnation of the "static initialization order
fiasco", but I did not take time to track down the exact problem with
4.2.2 yet.

HTH,
Filip


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