Access violation in boost::condition

Hi,
I'm using boost 1.33.1 on multi-processor plateform (2 Pentium4 3.2 GHz)
and Windows XP SP2 (compiled with MinGW).
I wrote a MessageQueue class which use boost::mutex and boost::condition
to wait for message and notify message reception (see code below)
I made a little test that create 2 boost::thread sending and receiving
messages in 2 queues.
The access violation is produced in the "WaitForSingleObject" method
called by "condition_impl::do_wait"
Have you ever meet this problem?
Eric Colleu
------messageQueue.cpp-----START
#include <iostream>
#include "messageQueue.hpp"
namespace util
{
MessageQueue::MessageQueue(void)
: m_mutex()
, m_condition()
, m_queue()
, m_cancel(false)
{
}
MessageQueue::~MessageQueue(void) throw()
{
}
void MessageQueue::push(MessageHandle message)
{
boost::mutex::scoped_lock lock(m_mutex);
m_queue.push(message);
m_condition.notify_all();
}
MessageHandle MessageQueue::pop(const boost::xtime& delay)
{
boost::mutex::scoped_lock lock(m_mutex);
while (m_queue.size() == 0)
{
if (!m_condition.timed_wait(lock, delay))
{
throw MsgTimeout("timeout in pop message");
}
}
if(m_cancel) {
m_cancel = false;
throw MsgWaitCancelled("Wait Event cancelled");
}
MessageHandle msg = m_queue.front();
m_queue.pop();
return msg;
}
MessageHandle MessageQueue::pop(void)
{
boost::mutex::scoped_lock lock(m_mutex);
while (m_queue.size() == 0 && ! m_cancel) {
m_condition.wait(lock);
}
if(m_cancel) {
m_cancel = false;
throw MsgWaitCancelled("Wait Event cancelled");
}
MessageHandle msg(m_queue.front());
m_queue.pop();
return msg;
}
int MessageQueue::size(void)
{
boost::mutex::scoped_lock lock(m_mutex);
return m_queue.size();
}
void MessageQueue::cancel_wait(void)
{
boost::mutex::scoped_lock lock(m_mutex);
m_cancel = true;
m_condition.notify_all();
}
}
------messageQueue.cpp-----END
------messageQueue.hpp-----START
#if defined(CORE_UTIL_QUEUE_MESSAGEQUEUE_CYCLE)
#error Header cyclic inclusion detected.
#endif // defined(CORE_UTIL_QUEUE_MESSAGEQUEUE_CYCLE)
#define CORE_UTIL_QUEUE_MESSAGEQUEUE_CYCLE
#if !defined(CORE_UTIL_QUEUE_MESSAGEQUEUE_HPP)
#define CORE_UTIL_QUEUE_MESSAGEQUEUE_HPP
// ===================================================================
#include <queue>
#include

On Thu, 22 Jun 2006 06:15:58 -0300, Eric Colleu
Hi,
I'm using boost 1.33.1 on multi-processor plateform (2 Pentium4 3.2 GHz) and Windows XP SP2 (compiled with MinGW). I wrote a MessageQueue class which use boost::mutex and boost::condition to wait for message and notify message reception (see code below) I made a little test that create 2 boost::thread sending and receiving messages in 2 queues.
I think you should poet the test. Bruno

Bruno Martínez a écrit :
On Thu, 22 Jun 2006 06:15:58 -0300, Eric Colleu
wrote: Hi,
I'm using boost 1.33.1 on multi-processor plateform (2 Pentium4 3.2 GHz) and Windows XP SP2 (compiled with MinGW). I wrote a MessageQueue class which use boost::mutex and boost::condition to wait for message and notify message reception (see code below) I made a little test that create 2 boost::thread sending and receiving messages in 2 queues.
I think you should poet the test.
Bruno
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
OK i found it finally. In GCC (under Linux and Windows), there is an access to the GLIBCPP_FORCE_NEW or GLIBCXX_FORCE_NEW environment variable (use a memory cache by default instead of calling malloc / free directly). On a multiprocessor system, this "optimisation" seems to be unstable. I set this variable and the problem disapear. So the problem is not in boost, sorry for my mistake. Eric
participants (2)
-
Bruno Martínez
-
Eric Colleu