
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