from libs/thread/mutex.cpp in boost 1.31, around line 211: void mutex::do_lock() { int res = 0; res = pthread_mutex_lock(&m_mutex); if (res == EDEADLK) throw lock_error(); assert(res == 0); } that last assert is failing for me. pthread_mutex_lock is returning 22 which if it's from sys/errno.h is EINVAL or "Invalid argument". any ideas? i built boost 1.31 on hpux 11.11 with a gcc from hp. some info:
gcc -v Reading specs from /usr/local/lib/gcc-lib/hppa2.0w-hp-hpux11.11/3.3.3/specs Configured with: /scratch/zack/pkgbuild/3.3.1/hpux-11/gcc-3.3.3/configure --enable-languages=c,c++ --enable-threads=posix --disable-nls --with-gnu-as --without-gnu-ld --with-as=/usr/local/bin/as --prefix=/usr/local Thread model: posix gcc version 3.3.3
uname -a HP-UX unknown B.11.11 U 9000/800 180901557 unlimited-user license
thanks, mike
Michael Garriss said the following on 12/16/04 10:46:
from libs/thread/mutex.cpp in boost 1.31, around line 211:
void mutex::do_lock() { int res = 0; res = pthread_mutex_lock(&m_mutex); if (res == EDEADLK) throw lock_error(); assert(res == 0); }
that last assert is failing for me. pthread_mutex_lock is returning 22 which if it's from sys/errno.h is EINVAL or "Invalid argument". any ideas?
i built boost 1.31 on hpux 11.11 with a gcc from hp. some info:
gcc -v Reading specs from /usr/local/lib/gcc-lib/hppa2.0w-hp-hpux11.11/3.3.3/specs Configured with: /scratch/zack/pkgbuild/3.3.1/hpux-11/gcc-3.3.3/configure --enable-languages=c,c++ --enable-threads=posix --disable-nls --with-gnu-as --without-gnu-ld --with-as=/usr/local/bin/as --prefix=/usr/local Thread model: posix gcc version 3.3.3
uname -a HP-UX unknown B.11.11 U 9000/800 180901557 unlimited-user license
thanks, mike _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
ok, this breaks with an assertrion failure:
#include
Michael Garriss said the following on 12/16/04 12:49:
Michael Garriss said the following on 12/16/04 10:46:
from libs/thread/mutex.cpp in boost 1.31, around line 211:
void mutex::do_lock() { int res = 0; res = pthread_mutex_lock(&m_mutex); if (res == EDEADLK) throw lock_error(); assert(res == 0); }
that last assert is failing for me. pthread_mutex_lock is returning 22 which if it's from sys/errno.h is EINVAL or "Invalid argument". any ideas?
i built boost 1.31 on hpux 11.11 with a gcc from hp. some info:
gcc -v Reading specs from /usr/local/lib/gcc-lib/hppa2.0w-hp-hpux11.11/3.3.3/specs Configured with: /scratch/zack/pkgbuild/3.3.1/hpux-11/gcc-3.3.3/configure --enable-languages=c,c++ --enable-threads=posix --disable-nls --with-gnu-as --without-gnu-ld --with-as=/usr/local/bin/as --prefix=/usr/local Thread model: posix gcc version 3.3.3
uname -a HP-UX unknown B.11.11 U 9000/800 180901557 unlimited-user license
thanks, mike _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
ok, this breaks with an assertrion failure:
#include
#include #include <iostream> struct count { boost::mutex mutex; count (int) { } void operator()() { boost::mutex::scoped_lock lock(mutex); std::cout << "Here" << std::endl; } }; int main(void) { count c(1); boost::thread thrd1(boost::ref(c)); thrd1.join(); return 0; } but this does not: #include
#include boost::mutex mutex; struct count { count (int) { } void operator()() { boost::mutex::scoped_lock lock(mutex); } }; int main(void) { boost::thread thrd1(count(0)); thrd1.join(); return 0; } --------------------------------------------------------------------------
--- mgarriss@hpux-test01 ~/test --- g++ -I /home/mgarriss/dev/tp-compiled/include/boost-1_31_0 -pthread test.cxx /home/mgarriss/dev/tp-compiled/lib/boost-1_31_0/libboost_thread-gcc-mt.a /usr/local/hppa2.0w-hp-hpux11.11/bin/nm: a.out: no symbols --- mgarriss@hpux-test01 ~/test --- ./a.out Assertion failed: _EX, file /home/mgarriss/dev/tp-sources/boost_1_31_0/libs/thread/src/mutex.cpp, line 211 ABORT instruction (core dumped)
it also breaks on making mutex a static class member. so in summary it only works (i think) if the mutex is a member var.
Mike _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
err. those exmaples got mixed up (thx Bklyn). global mutex breaks it and member var mutex works. sorry for the noise, mike
Michael Garriss wrote:
err. those exmaples got mixed up (thx Bklyn). global mutex breaks it and member var mutex works.
Using a global mutex causes the pthread_mutex_init to be called before main. A quick poll on the comp.programmin.threads showed the answer that this should be allowed. However I am still suspicious. For one you are getting this unexpected error, for the other pthread defines a special PTHREAD_MUTEX_INITIALIZER, which causes the mutex to be initialized on first use. But boost.threads is not using this. We need to look into this. BTW. the code compiles and runs correctly on windows. (altough I did not manage yet to test it win pthreads-win32 port.) Roland
Roland Schwarz wrote:
Michael Garriss wrote:
err. those exmaples got mixed up (thx Bklyn). global mutex breaks it and member var mutex works.
Using a global mutex causes the pthread_mutex_init to be called before main. A quick poll on the comp.programmin.threads showed the answer that this should be allowed. However I am still suspicious.
Beeing back from comp.alt.programming.threads I have to say that the current boost usage of the pthreads lib seems to be the culprit. Altough there seems to exist a recommendation to use mutexes in a global manner, the way boost is using this at the moment seems to prevent exactly this case. For the time being I recommend to avoid this usage. It has to be discussed if the situation can be improved. However in any case I suspect boost.thread will need to add the prerequisite of not allowing any use of the mutex before main has started up. I.e. specifically no threads may be started from global ctors. But please don't take this for granted now. More research will need to take place. regards, Roland
Roland Schwarz wrote:
Michael Garriss wrote:
err. those exmaples got mixed up (thx Bklyn). global mutex breaks it and member var mutex works.
Using a global mutex causes the pthread_mutex_init to be called before main. A quick poll on the comp.programmin.threads showed the answer that this should be allowed. However I am still suspicious.
Beeing back from comp.alt.programming.threads I have to say that the current boost usage of the pthreads lib seems to be the culprit. Altough there seems to exist a recommendation to use mutexes in a global manner, the way boost is using this at the moment seems to prevent exactly this case. For the time being I recommend to avoid this usage. It has to be discussed if the situation can be improved. However in any case I suspect boost.thread will need to add the prerequisite of not allowing any use of the mutex before main has started up. I.e. specifically no threads may be started from global ctors. But please don't take this for granted now. More research will need to take place. regards, Roland
participants (2)
-
Michael Garriss
-
Roland Schwarz