[pool] Crash when attempting to call malloc (1.32)

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)

AMDG James Madison wrote:
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(...);
What is random_structure->memoryPool?
<snip> 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?
It should be safe to use different pools in different threads. It is not safe to use the same pool from different threads without locking.
(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)
In Christ, Steven Watanabe

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?
The pool allocators are thread safe, pool as such is not.
(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)
I have reviewed the pool code quite thoroughly after having some issues with it, and I think the code is OK in the Boost version that I'm using now (1.38). Cheers, Filip
participants (3)
-
Filip Konvička
-
James Madison
-
Steven Watanabe