[Mutli-Index, InterProcess] Multi-index stability issue with interprocess?
I am creating a multi-index on three members of a class (two int32_t and one std::pair<int32_t, int32_t> and storing that in a managed memory mapped file (boos::interprocess). I am using GCC 4.8.2 for compilation and boost version 1.56.beta1All the data is first inserted into the multi-index once and then it is read from the muti-index with a query on the first two int32_t values (There is no concurrency and insertion and query is being done within the same process). The mutliindex is defined as: typedef bmi::multi_index_container < Trace, bmi::indexed_by < bmi::ordered_non_unique < bmi::composite_key < Trace, BOOST_MULTI_INDEX_MEMBER(Trace, int32_t, m_x), BOOST_MULTI_INDEX_MEMBER(Trace, int32_t, m_y), BOOST_MULTI_INDEX_MEMBER(Trace, int_pair_t, m_volume) > > > , managed_mapped_file::allocator<Trace>::type > trace_set_t; The query is: boost::tie(l, u) = m_p_mi_ts->get<0>().equal_range(boost::make_tuple(i, j)); We are testing this whole process over and over again (each iteration is a new run of the process), and once in every 50 or so iterations we get a segment fault inside boost on firing the query. Here is the boost part of the stack from the core dump: #0 0x00002b748b6ac0ec in boost::interprocess::offset_ptr<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<Seismic::Data::Trace, boost::interprocess::allocator<Seismic::Data::Trace, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index> > > >, long, unsigned long, 0ul>::get() const () at /glb/data/ifshou_cdis05/projects/cdis/installed/boost/1.56.0.beta1/usr/local/include/boost/interprocess/offset_ptr.hpp:346#1 0x00002b748b6a8934 in boost::interprocess::offset_ptr<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<Seismic::Data::Trace, boost::interprocess::allocator<Seismic::Data::Trace, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index> > > >, long, unsigned long, 0ul>::operator*() const () at /glb/data/ifshou_cdis05/projects/cdis/installed/boost/1.56.0.beta1/usr/local/include/boost/interprocess/offset_ptr.hpp:360#2 0x00002b748b6a5932 in boost::multi_index::multi_index_container<Seismic::Data::Trace, boost::multi_index::indexed_by<boost::multi_index::ordered_non_unique<boost::multi_index::composite_key<Seismic::Data::Trace, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_x)>, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_y)>, boost::multi_index::member<Seismic::Data::Trace, std::pair<int, int>, &(Seismic::Data::Trace::m_volume)>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, mpl_::na, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::interprocess::allocator<Seismic::Data::Trace, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index> > >::header() const () at /glb/data/ifshou_cdis05/projects/cdis/installed/boost/1.56.0.beta1/usr/local/include/boost/multi_index_container.hpp:525#3 0x00002b748b6a3250 in boost::multi_index::detail::index_base<Seismic::Data::Trace, boost::multi_index::indexed_by<boost::multi_index::ordered_non_unique<boost::multi_index::composite_key<Seismic::Data::Trace, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_x)>, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_y)>, boost::multi_index::member<Seismic::Data::Trace, std::pair<int, int>, &(Seismic::Data::Trace::m_volume)>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, mpl_::na, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::interprocess::allocator<Seismic::Data::Trace, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index> > >::final_header() const () at /glb/data/ifshou_cdis05/projects/cdis/installed/boost/1.56.0.beta1/usr/local/include/boost/multi_index/detail/index_base.hpp:212#4 0x00002b748b6a022c in boost::multi_index::detail::ordered_index<boost::multi_index::composite_key<Seismic::Data::Trace, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_x)>, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_y)>, boost::multi_index::member<Seismic::Data::Trace, std::pair<int, int>, &(Seismic::Data::Trace::m_volume)>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<Seismic::Data::Trace, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_x)>, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_y)>, boost::multi_index::member<Seismic::Data::Trace, std::pair<int, int>, &(Seismic::Data::Trace::m_volume)>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >, boost::multi_index::detail::nth_layer<1, Seismic::Data::Trace, boost::multi_index::indexed_by<boost::multi_index::ordered_non_unique<boost::multi_index::composite_key<Seismic::Data::Trace, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_x)>, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_y)>, boost::multi_index::member<Seismic::Data::Trace, std::pair<int, int>, &(Seismic::Data::Trace::m_volume)>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, mpl_::na, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::interprocess::allocator<Seismic::Data::Trace, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index> > >, boost::mpl::vector0<mpl_::na>, boost::multi_index::detail::ordered_non_unique_tag>::header() const () at /glb/data/ifshou_cdis05/projects/cdis/installed/boost/1.56.0.beta1/usr/local/include/boost/multi_index/ordered_index.hpp:973#5 0x00002b748b69cbed in std::pair<boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<Seismic::Data::Trace, boost::interprocess::allocator<Seismic::Data::Trace, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index> > > > >, boost::multi_index::detail::bidir_node_iterator<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::index_node_base<Seismic::Data::Trace, boost::interprocess::allocator<Seismic::Data::Trace, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index> > > > > > boost::multi_index::detail::ordered_index<boost::multi_index::composite_key<Seismic::Data::Trace, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_x)>, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_y)>, boost::multi_index::member<Seismic::Data::Trace, std::pair<int, int>, &(Seismic::Data::Trace::m_volume)>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, std::less<boost::multi_index::composite_key_result<boost::multi_index::composite_key<Seismic::Data::Trace, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_x)>, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_y)>, boost::multi_index::member<Seismic::Data::Trace, std::pair<int, int>, &(Seismic::Data::Trace::m_volume)>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >, boost::multi_index::detail::nth_layer<1, Seismic::Data::Trace, boost::multi_index::indexed_by<boost::multi_index::ordered_non_unique<boost::multi_index::composite_key<Seismic::Data::Trace, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_x)>, boost::multi_index::member<Seismic::Data::Trace, int, &(Seismic::Data::Trace::m_y)>, boost::multi_index::member<Seismic::Data::Trace, std::pair<int, int>, &(Seismic::Data::Trace::m_volume)>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, mpl_::na, mpl_::na>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::interprocess::allocator<Seismic::Data::Trace, boost::interprocess::segment_manager<char, boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index> > >, boost::mpl::vector0<mpl_::na>, boost::multi_index::detail::ordered_non_unique_tag>::equal_range<boost::tuples::tuple<int, int, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >(boost::tuples::tuple<int, int, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> const&) const () at /glb/data/ifshou_cdis05/projects/cdis/installed/boost/1.56.0.beta1/usr/local/include/boost/multi_index/ordered_index.hpp:556 Any idea what might be happening? Thanks
vibhor aggarwal <vibhor.aggarwal <at> yahoo.com> writes:
I am creating a multi-index [...] and storing that in a managed memory mapped file (boos::interprocess) [...] All the data is first inserted into the multi-index once and then it is read from the muti-index with a query [...]
boost::tie(l, u) = m_p_mi_ts->get<0>(). equal_range(boost::make_tuple(i, j));
We are testing this whole process over and over again (each iteration is a new run of the process), and once in every 50 or so iterations we get a segment fault inside boost on firing the query. Here is the boost part of the stack from the core dump:
With so little information, I can only guess: the crash is hapenning at a very superficial level into equal_range, namely when dereferencing the container's header node (the top of the rb-tree ordered indices are based on). This suggests that the container layout is seriously screwed; possible reasons: * Memory overwrites from some adjacent structure * File corruption (?) * m_p_mi has been changed somewhere * Some sort of overrun within the memory-mapped file It'd be best if you could provide a testing case for this or some more context. If this is not an option, you can activate Boost.MultiIndex invariant-checking mode: http://www.boost.org/libs/multi_index/doc/tutorial /debug.html#invariant_check which will assert as soon as some internal corruption is detected (caveat: this mode will reduce performance drastically). Joaquín M López Muñoz Telefónica
participants (2)
-
Joaquin M Lopez Munoz
-
vibhor aggarwal