Subject: [Boost-bugs] [Boost C++ Libraries] #4648: boost::lock_error Thrown While Using Upgrade Locks
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-09-14 05:18:55
#4648: boost::lock_error Thrown While Using Upgrade Locks
------------------------------------------------------------+---------------
Reporter: bornlibra23 | Owner: anthonyw
Type: Support Requests | Status: new
Milestone: To Be Determined | Component: thread
Version: Boost 1.43.0 | Severity: Problem
Keywords: Boost.Thread boost::lock_error Synchronization |
------------------------------------------------------------+---------------
Hello
I am trying to model a usecase where a member function reads in a value &
now has to modify the value by calling another function. The code which I
have written using upgrade_locks fails at run time. I have gone through
the documentation & have cleared the code as best as I could to arrive at
a condensed usecase. I have also attached some sample errorenous outputs &
a backtrace of the threaad in question. Can someone please have a look?
Linux architecture_233 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 EST 2008
x86_64 x86_64 x86_64 GNU/Linux
GNU C Library stable release version 2.5, by Roland McGrath et al.
Compiled by GNU CC version 4.1.2 20080704 (Red Hat 4.1.2-44).
Compiled on a Linux 2.6.9 system on 2009-01-05.
Available extensions:
The C stubs add-on version 2.1.2.
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
GNU libio by Per Bothner
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
RT using linux kernel aio
Thread-local storage support included.
#include <iostream>
#include <boost/thread.hpp>
class boostThreadLocksTest
{
public:
boost::shared_mutex myMutex;
boost::upgrade_lock<boost::shared_mutex> myLock;
static int firstFunction(boostThreadLocksTest
*pBoostThreadLocksTest);
static int secondFunction(boostThreadLocksTest
*pBoostThreadLocksTest);
boostThreadLocksTest():myMutex(),myLock(myMutex,boost::defer_lock_t()){};
};
int boostThreadLocksTest::firstFunction(boostThreadLocksTest
*pBoostThreadLocksTest)
{
std::cout<<"Before Locking
"<<boost::this_thread::get_id()<<" "<<__PRETTY_FUNCTION__<<std::endl;
pBoostThreadLocksTest->myLock.lock();
std::cout<<"After Locking
"<<boost::this_thread::get_id()<<" "<<__PRETTY_FUNCTION__<<std::endl;
pBoostThreadLocksTest->secondFunction(pBoostThreadLocksTest);
std::cout<<"Returned From Call
"<<boost::this_thread::get_id()<<" "<<__PRETTY_FUNCTION__<<std::endl;
pBoostThreadLocksTest->myLock.unlock();
std::cout<<"After Unlocking
"<<boost::this_thread::get_id()<<" "<<__PRETTY_FUNCTION__<<std::endl;
return(0);
}
int boostThreadLocksTest::secondFunction(boostThreadLocksTest
*pBoostThreadLocksTest)
{
std::cout<<"Before Exclusive Locking
"<<boost::this_thread::get_id()<<" "<<__PRETTY_FUNCTION__<<std::endl;
boost::upgrade_to_unique_lock<boost::shared_mutex>
localUniqueLock(pBoostThreadLocksTest->myLock);
std::cout<<"After Exclusive Locking
"<<boost::this_thread::get_id()<<" "<<__PRETTY_FUNCTION__<<std::endl;
return(0);
}
int main()
{
boostThreadLocksTest myObject;
boost::thread_group myThreadGroup;
myThreadGroup.create_thread(boost::bind(boostThreadLocksTest::firstFunction,&myObject));
myThreadGroup.create_thread(boost::bind(boostThreadLocksTest::firstFunction,&myObject));
myThreadGroup.create_thread(boost::bind(boostThreadLocksTest::firstFunction,&myObject));
myThreadGroup.join_all();
}
/*
Before Locking 0x7694120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
After Locking 0x7694120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Before Exclusive Locking 0x7694120 static int
boostThreadLocksTest::secondFunction(boostThreadLocksTest*)
After Exclusive Locking 0x7694120 static int
boostThreadLocksTest::secondFunction(boostThreadLocksTest*)
Returned From Call 0x7694120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
After Unlocking 0x7694120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Before Locking 0x76943e0 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
After Locking 0x76943e0 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Before Exclusive Locking 0x76943e0 static int
boostThreadLocksTest::secondFunction(boostThreadLocksTest*)
After Exclusive Locking 0x76943e0 static int
boostThreadLocksTest::secondFunction(boostThreadLocksTest*)
Before Locking 0x76946e0 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Returned From Call 0x76943e0 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error>
>'
what(): boost::lock_error
Aborted
Before Locking 0x1888e120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
After Locking 0x1888e120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Before Exclusive Locking 0x1888e120 static int
boostThreadLocksTest::secondFunction(boostThreadLocksTest*)
After Exclusive Locking 0x1888e120 static int
boostThreadLocksTest::secondFunction(boostThreadLocksTest*)
Before Locking 0x1888e3e0 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Returned From Call 0x1888e120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error>
>'
what(): boost::lock_error
Returned From Call 0x1888e120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Aborted
Before Locking 0x18f62120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
After Locking 0x18f62120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Before Exclusive Locking 0x18f62120 static int
boostThreadLocksTest::secondFunction(boostThreadLocksTest*)
After Exclusive Locking 0x18f62120 static int
boostThreadLocksTest::secondFunction(boostThreadLocksTest*)
Before Locking 0x18f623e0 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Returned From Call 0x18f62120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error>
>'
what(): boost::lock_error
Returned From Call 0x18f62120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Aborted
Before Locking 0x1a2a1120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
After Locking 0x1a2a1120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Before Exclusive Locking 0x1a2a1120 static int
boostThreadLocksTest::secondFunction(boostThreadLocksTest*)
After Exclusive Locking 0x1a2a1120 static int
boostThreadLocksTest::secondFunction(boostThreadLocksTest*)
Before Locking 0x1a2a13e0 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Returned From Call 0x1a2a1120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error>
>'
what(): boost::lock_error
Returned From Call 0x1a2a1120 static int
boostThreadLocksTest::firstFunction(boostThreadLocksTest*)
Aborted
*/
Program terminated with signal 6, Aborted.
[New process 9574]
[New process 9573]
[New process 9571]
#0 0x00000039f8430215 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00000039f8430215 in raise () from /lib64/libc.so.6
#1 0x00000039f8431cc0 in abort () from /lib64/libc.so.6
#2 0x00000039fa0bec44 in __gnu_cxx::__verbose_terminate_handler () from
/usr/lib64/libstdc++.so.6
#3 0x00000039fa0bcdb6 in ?? () from /usr/lib64/libstdc++.so.6
#4 0x00000039fa0bcde3 in std::terminate () from /usr/lib64/libstdc++.so.6
#5 0x00000039fa0bceca in __cxa_throw () from /usr/lib64/libstdc++.so.6
#6 0x00000000004108cf in boost::throw_exception<boost::lock_error> ()
#7 0x000000000041a1a0 in boost::upgrade_lock<boost::shared_mutex>::lock
()
#8 0x0000000000405e19 in boostThreadLocksTest::firstFunction ()
#9 0x0000000000409c36 in
boost::_bi::list1<boost::_bi::value<boostThreadLocksTest*>
>::operator()<int, int (*)(boostThreadLocksTest*), boost::_bi::list0> ()
#10 0x0000000000409c74 in boost::_bi::bind_t<int, int
(*)(boostThreadLocksTest*),
boost::_bi::list1<boost::_bi::value<boostThreadLocksTest*> > >::operator()
()
#11 0x0000000000409c92 in
boost::detail::thread_data<boost::_bi::bind_t<int, int
(*)(boostThreadLocksTest*),
boost::_bi::list1<boost::_bi::value<boostThreadLocksTest*> > > >::run ()
#12 0x00002b627c120bbb in thread_proxy () from
/usr/local/lib/libboost_thread.so.1.43.0
#13 0x00000039f9006367 in start_thread () from /lib64/libpthread.so.0
#14 0x00000039f84d30ad in clone () from /lib64/libc.so.6
#0 0x00000039f84c56db in write () from /lib64/libc.so.6
#1 0x00000039f846ba63 in _IO_new_file_write () from /lib64/libc.so.6
#2 0x00000039f846b976 in _IO_new_do_write () from /lib64/libc.so.6
#3 0x00000039f846c0f4 in _IO_new_file_overflow () from /lib64/libc.so.6
#4 0x00000039f8469286 in putc () from /lib64/libc.so.6
#5 0x00000039fa08ff2f in std::ostream::put () from
/usr/lib64/libstdc++.so.6
#6 0x00000039fa090010 in std::endl<char, std::char_traits<char> > () from
/usr/lib64/libstdc++.so.6
#7 0x0000000000405d4a in boostThreadLocksTest::secondFunction ()
#8 0x0000000000405e9b in boostThreadLocksTest::firstFunction ()
#9 0x0000000000409c36 in
boost::_bi::list1<boost::_bi::value<boostThreadLocksTest*>
>::operator()<int, int (*)(boostThreadLocksTest*), boost::_bi::list0> ()
#10 0x0000000000409c74 in boost::_bi::bind_t<int, int
(*)(boostThreadLocksTest*),
boost::_bi::list1<boost::_bi::value<boostThreadLocksTest*> > >::operator()
()
#11 0x0000000000409c92 in
boost::detail::thread_data<boost::_bi::bind_t<int, int
(*)(boostThreadLocksTest*),
boost::_bi::list1<boost::_bi::value<boostThreadLocksTest*> > > >::run ()
#12 0x00002b627c120bbb in thread_proxy () from
/usr/local/lib/libboost_thread.so.1.43.0
#13 0x00000039f9006367 in start_thread () from /lib64/libpthread.so.0
#14 0x00000039f84d30ad in clone () from /lib64/libc.so.6
#0 0x00000039f900a899 in pthread_cond_wait@@GLIBC_2.3.2 () from
/lib64/libpthread.so.0
#1 0x00002b627c1224e7 in boost::thread::join () from
/usr/local/lib/libboost_thread.so.1.43.0
#2 0x000000000041aa47 in boost::thread_group::join_all ()
#3 0x0000000000405be3 in main ()
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4648> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC