I am experiencing a very rare crash with boost::pool, when attempting to call malloc(), using boost 1.32.  Specifically:

In the header:

boost::object_pool<unsigned long long> m_cdPool;

In the code in Thread 1:

unsigned long long key* = m_cdPool.malloc();

In the code in Thread 2:

random_structure->memoryPool->free(...);

I am crashing on a call to

simple_segregated_storage<unsigned int>::malloc() within boost, specifically in the following method, where at the end of the method ret contains an inaccessable memory address.


    // pre: !empty()

    void * malloc()

    {

      void * const ret = first;

 

      // Increment the "first" pointer to point to the next chunk

      first = nextof(first);

      return ret;

    }


I am wondering if anyone has experienced anything similar, and knows what might be happening.


Also, about threads.  This is being malloced/free in two separate threads, however I sort of assumed that pool was thread safe because of discussion about using boost::thread instead of their current scheme for thread safety on another mailing list.  Was my assumption wrong, i.e. pool is not thread safe?


(I am a little hesitant to blame this completely on threading without searching a bit elsewhere because of the way the three threads operate, there is very little chance they are stomping over the pool, and the other threads are also all in wait states when this occurs)