c++ - Application boost::thread stuck on mutex lock when compiled for ARM running on BeagleBone Black -
i working on c++ app runs on pc fine , want make work on beaglebone black on have installed debian wheezy.
i'm cross compiling using eldk v5.3 , qmake pc (intel celeron, debian wheezy, boost v1.49.0-3.2) beaglebone black (arm cortex a8, debian wheezy, boost v1.49.0-3.2).
everything works should, every , then, app freezes (is stuck on __pthread_mutex_lock) when boost::thread created or app waiting boost::thread::join(). want understand what's going on.
if have tips can me secure these calls boost::thread (try/catch, error status check ...) please share them :)
thank !!
here small source code freezes in similar fashion when executed on beaglebone black followed backtrace printed when app freezes (gdb) , .pro file used when executing qmake command :
#include <stdio.h> #include <boost/thread.hpp> #define nb_threads 20 #define thread_life_duration 5 int g_nb_thread = 0; boost::thread * subregisterthread(boost::thread * pthread) { printf("register thread #%d %p created\n", g_nb_thread++, pthread); return pthread; } /////////////////// sub dummy class class sub_dummy_class { public: boost::thread *mthread; sub_dummy_class(); ~sub_dummy_class(); void loop(); void start(); }; sub_dummy_class::sub_dummy_class() { mthread = null; } sub_dummy_class::~sub_dummy_class() { if(mthread) { mthread->join(); } } void sub_dummy_class::start() { mthread = subregisterthread(new boost::thread(boost::bind(&sub_dummy_class::loop, this))); } void sub_dummy_class::loop() { int life_duration = thread_life_duration; while(life_duration > 0) { life_duration--; printf("got %d seconds live !\n", life_duration); usleep(1000000); } return; } ////////////////////////// dummy class class dummy_class { public: sub_dummy_class dummies[nb_threads]; dummy_class(); ~dummy_class(); void start(); }; dummy_class::dummy_class() { } dummy_class::~dummy_class() { } void dummy_class::start() { for(int = 0 ; < nb_threads ; i++) { dummies[i].start(); } } int main(int argc, char* argv[]) { printf("starting program\n"); printf("creating dummy class\n"); dummy_class *dc = new dummy_class(); printf("starting dummy class\n"); dc->start(); printf("deleting dummy class\n"); delete dc; return 0; }
stack trace :
(gdb) bt #0 __libc_do_syscall () @ ../ports/sysdeps/unix/sysv/linux/arm/eabi/libc-do-syscall.s:44 #1 0xb6756f92 in __lll_lock_wait (futex=0x1881c, private=0) @ ../ports/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.c:47 #2 0xb675357a in __pthread_mutex_lock (mutex=0x1881c) @ pthread_mutex_lock.c:61 #3 0xb68029dc in pthread_mutex_lock (mutex=<optimized out>) @ forward.c:182 #4 0xb6991710 in lock (this=0xb69a2c68) @ ./boost/smart_ptr/detail/spinlock_pt.hpp:41 #5 scoped_lock (pv=0x1f714, this=<synthetic pointer>) @ ./boost/smart_ptr/detail/spinlock_pool.hpp:65 #6 atomic_increment (pw=0x1f714) @ ./boost/smart_ptr/detail/sp_counted_base_spin.hpp:41 #7 add_ref_copy (this=0x1f710) @ ./boost/smart_ptr/detail/sp_counted_base_spin.hpp:90 #8 shared_count (r=..., this=<optimized out>) @ ./boost/smart_ptr/detail/shared_count.hpp:316 #9 shared_ptr (this=<optimized out>) @ ./boost/smart_ptr/shared_ptr.hpp:164 #10 operator= (r=..., this=0x1f604) @ ./boost/smart_ptr/shared_ptr.hpp:311 #11 boost::thread::start_thread (this=0x1f5e8) @ libs/thread/src/pthread/thread.cpp:185 #12 0x0000cf7c in boost::thread::thread<boost::_bi::bind_t<void, boost::_mfi::mf0<void, sub_dummy_class>, boost::_bi::list1<boost::_bi::value<sub_dummy_class*> > > > (this=0x1f5e8, f=...) @ /opt/eldk-5.3/armv7a-hf/sysroots/armv7ahf-vfp-neon-linux-gnueabi/usr/include/boost/thread/detail/thread.hpp:205 #13 0x0000aa44 in sub_dummy_class::start (this=0x1cfdc) @ main.cpp:51 #14 0x0000abc4 in dummy_class::start (this=0x1cf90) @ main.cpp:96 #15 0x0000ac44 in main (argc=1, argv=0xbefff834) @ main.cpp:109
edit : here .pro file i'm using qmake command (qmake -spec linux-armv7a-hf-g++) :
# .pro test_boost template = app config = qt -= qt webkit target = test_boost_arm qmake_lflags += -wl,-rpath ./ qmake_lflags_rpath = headers = sources = main.cpp other_files = destdir = . # external libs libs += -lboost_thread
i tested these 2 parameters bit. when nb_threads=15, seems go fine every time when it's equal 16, freezes. thread_life_duration doesn't seem have effect on program's behaviour. hope understand what's going on.
looks upgrade of boost version 1.54 fixes issue. took time right packages because debian wheezy's boost stable release 1.49, had manually upgrade cross-compilation platform.
the app can run 380 threads without problems, more enough me.
Comments
Post a Comment