shared_array EXC_BAD_ACCESS

Hi there, I'm attempting to use a shared_array as member of a class that I have. Something akin to the following: class UTFStringHolder { ... boost::shared_array<unsigned short> mStrBufferP; }; When UTFStringHolder is instantiated, I get an EXC_BAD_ACCESS and my stack trace shows that pthread_mutex_init is being called. Here's the complete stack trace: #0 0x90012730 in _pthread_mutex_init #1 0x00088424 in boost::detail::lightweight_mutex::lightweight_mutex() at lwm_pthreads.hpp:47 #2 0x00088024 in boost::detail::lightweight_mutex::lightweight_mutex() at lwm_pthreads.hpp:49 #3 0x00087bc4 in boost::detail::sp_counted_base::sp_counted_base() at shared_count.hpp:98 #4 0x00086614 in boost::detail::sp_counted_base::sp_counted_base() at shared_count.hpp:99 #5 0x00098be0 in boost::detail::sp_counted_base_impl<unsigned short*, boost::checked_array_deleter<unsigned short>
::sp_counted_base_impl(unsigned short*, boost::checked_array_deleter<unsigned short>) at shared_count.hpp:253 #6 0x00098b8c in boost::detail::sp_counted_base_impl<unsigned short*, boost::checked_array_deleter<unsigned short> ::sp_counted_base_impl(unsigned short*, boost::checked_array_deleter<unsigned short>) at shared_count.hpp:253 #7 0x00098ac4 in boost::detail::shared_count::shared_count<unsigned short*, boost::checked_array_deleter<unsigned short> >(unsigned short*, boost::checked_array_deleter<unsigned short>) at shared_count.hpp:340 #8 0x00098a48 in boost::detail::shared_count::shared_count<unsigned short*, boost::checked_array_deleter<unsigned short> >(unsigned short*, boost::checked_array_deleter<unsigned short>) at shared_count.hpp:345 #9 0x00098900 in boost::shared_array<unsigned short>::shared_array(unsigned short*) at shared_array.hpp:57 #10 0x0009889c in boost::shared_array<unsigned short>::shared_array(unsigned short*) at shared_array.hpp:57 #11 0x00029f34 in Classee::UTFStringHolder::UTFStringHolder() at UTFString.cpp:20
Any ideas/pointers? I'm using boost v.1.32. Thanks for any help as I'm going bonkers. :-P Cheers, -C

Christopher Hunt wrote:
Hi there,
I'm attempting to use a shared_array as member of a class that I have. Something akin to the following:
class UTFStringHolder { ...
boost::shared_array<unsigned short> mStrBufferP; };
When UTFStringHolder is instantiated, I get an EXC_BAD_ACCESS and my stack trace shows that pthread_mutex_init is being called. Here's the complete stack trace:
#0 0x90012730 in _pthread_mutex_init #1 0x00088424 in boost::detail::lightweight_mutex::lightweight_mutex() at lwm_pthreads.hpp:47
These things usually happen when you have inconsistent definitions of BOOST_HAS_THREADS in the source files or libraries that form your program. Does the code still fail when you try it as a single self-contained source file? If it does, can you post a minimal example that fails?
participants (2)
-
Christopher Hunt
-
Peter Dimov