Boost logo

Boost Users :

Subject: [Boost-users] linking to boost thread exposes static initialisation order fiasco in ublas?
From: David Philp (david.philp_at_[hidden])
Date: 2008-09-17 22:53:19


Hi

This is a weird issue, and I'm by no means sure that my description is
correct. It might be a newbie misunderstanding, but it is weird
behaviour and I would appreciate any help in getting to the bottom of
it.

Here is a minimal example that exhibits the issue: ("zeromain.cpp")

#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/thread.hpp>

int main (int argc, char * argv[])
{
   boost::numeric::ublas::coordinate_matrix<double> cm;
   cm.resize(3,3, false);
   return 0;
}

When compiled [with bjam release] and linked to libboost_thread it
gives a "bus error". The backtrace is appended to this email. It
works fine in debug mode.

You can see that I have introduced boost.thread but not yet actually
used the thread library in any way. If I take out either the include,
or don't link to the lib, the bug goes away.

Thanks in advance for any help or suggestions! Details below.

David

Mac OS X 1.5.5, boost 1.36. Intel CPU.
The boost libraries are in $DYLD_LIBRARY_PATH.
Jamroot contains
exe zm
   : zeromain.cpp /sage//boost_thread
   : <include>boost
   ;
("sage" is a separate project whose Jamroot contains
lib boost_thread : : <file>local/lib/boost/libboost_thread-xgcc40-
mt-1_36.a ;
It is a regular build of the boost libraries.)

Backtrace:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x00001f24 in boost::numeric::ublas::coordinate_matrix<double,
boost::numeric::ublas::basic_row_major<unsigned long, int>, 0ul,
boost::numeric::ublas::unbounded_array<unsigned long,
std::allocator<unsigned long> >,
boost::numeric::ublas::unbounded_array<double, std::allocator<double>
> >::coordinate_matrix ()
(gdb) bt
#0 0x00001f24 in boost::numeric::ublas::coordinate_matrix<double,
boost::numeric::ublas::basic_row_major<unsigned long, int>, 0ul,
boost::numeric::ublas::unbounded_array<unsigned long,
std::allocator<unsigned long> >,
boost::numeric::ublas::unbounded_array<double, std::allocator<double>
> >::coordinate_matrix ()
#1 0x8fe12e76 in
__dyld__ZN16ImageLoaderMachO18doModInitFunctionsERKN11ImageLoader11LinkContextE
  ()
#2 0x8fe0e723 in
__dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#3 0x8fe0e809 in
__dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextE ()
#4 0x8fe04102 in __dyld__ZN4dyld24initializeMainExecutableEv ()
#5 0x8fe07b5f in __dyld__ZN4dyld5_mainEPK11mach_headermiPPKcS5_S5_ ()
#6 0x8fe01872 in
__dyld__ZN13dyldbootstrap5startEPK11mach_headeriPPKcl ()
#7 0x8fe01037 in __dyld__dyld_start ()


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net