Boost scoped_lock failed every time

In the class I want to use a mutex over such a function

void Agent::notify(Packet& packet, Peer peer) {
    boost::mutex::scoped_lock lock(mutex_);
    ...
}

No compilation issues. But when I run the program, boost always fails on this line, saying:

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error> >'
  what():  boost: mutex lock failed in pthread_mutex_lock: Invalid argument
Abandon (core dumped)

I am trying to use methods lock()or unlock, but the same problem. When I use try_lock, this is not a failure provided that the condition is always incorrect.

Searching the Internet I found this https://svn.boost.org/trac/boost/ticket/9307 .

But I think the problem is in my program, but I do not see where. In my tests, there is only one thread that goes into this function.

0
source share
1 answer

, , , . , , . .

0

All Articles