Hi. I seem to have found a minor bug in ip_allocator example.
In debug mode (boost 1.90), I start the program in linux, insert one book record, then exit.
I start again and try to show the previous record and it just crashed.
# ./a.out
1. list books by author
2. list all books by prize
3. insert a book
4. delete a book
0. exit
command: 1
author (empty=all authors): cshi
Segmentation fault (core dumped)
Here's the backtrace:
Core was generated by `./a.out'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00000000004165e8 in boost::interprocess::offset_ptr<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<book, boost::interprocess::allocator<book, 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 (this=0x7ffff7e97118) at /data/opt/boost/include/boost/interprocess/offset_ptr.hpp:392
392 { return static_cast<pointer>(ipcdetail::offset_ptr_to_raw_pointer(this, this->internal.m_offset)); }
[#0] boost::interprocess::offset_ptr<boost::multi_index::detail::ordered_index_node<…>, long, unsigned long, 0ul>::get (/data/opt/boost/include/boost/interprocess/offset_ptr.hpp:392)
[#1] boost::interprocess::offset_ptr<boost::multi_index::detail::ordered_index_node<…>, long, unsigned long, 0ul>::operator* (/data/opt/boost/include/boost/interprocess/offset_ptr.hpp:406)
[#2] boost::multi_index::multi_index_container<book, boost::multi_index::indexed_by<…>, boost::interprocess::allocator<…> >::header (/data/opt/boost/include/boost/multi_index_container.hpp:640)
[#3] boost::multi_index::detail::index_base<book, boost::multi_index::indexed_by<…>, boost::interprocess::allocator<…> >::final_header (/data/opt/boost/include/boost/multi_index/detail/index_base.hpp:221)
[#4] boost::multi_index::detail::ordered_index_impl<…>::header (/data/opt/boost/include/boost/multi_index/detail/ord_index_impl.hpp:1131)
[#5] boost::multi_index::detail::ordered_index_impl<…>::end (/data/opt/boost/include/boost/multi_index/detail/ord_index_impl.hpp:262)
[#6] boost::multi_index::detail::any_container_view<boost::multi_index::safe_mode::safe_iterator<…> >::end_for<boost::multi_index::detail::ordered_index_impl<…> > (/data/opt/boost/include/boost/multi_index/detail/any_container_view.hpp:51)
[#7] boost::multi_index::detail::any_container_view<boost::multi_index::safe_mode::safe_iterator<…> >::end (/data/opt/boost/include/boost/multi_index/detail/any_container_view.hpp:33)
[#8] boost::multi_index::safe_mode::safe_container<boost::multi_index::safe_mode::safe_iterator<…> >::end (/data/opt/boost/include/boost/multi_index/detail/safe_mode.hpp:593)
[#9] boost::multi_index::safe_mode::check_dereferenceable_iterator<boost::multi_index::safe_mode::safe_iterator<…> > (/data/opt/boost/include/boost/multi_index/detail/safe_mode.hpp:158)
[#10] boost::multi_index::safe_mode::safe_iterator<…>::dereference (/data/opt/boost/include/boost/multi_index/detail/safe_mode.hpp:500)
[#11] boost::multi_index::detail::iter_adaptor_access::dereference<boost::multi_index::safe_mode::safe_iterator<…> > (/data/opt/boost/include/boost/multi_index/detail/iter_adaptor.hpp:44)
[#12] boost::multi_index::detail::bidirectional_iter_adaptor_base<…>::operator* (/data/opt/boost/include/boost/multi_index/detail/iter_adaptor.hpp:148)
[#13] std::__copy_move<false, false, std::bidirectional_iterator_tag>::__copy_m<…> (/data/opt/gcc-13.3.0/include/c++/13.3.0/bits/stl_algobase.h:356)
[#14] std::__copy_move_a2<…> (/data/opt/gcc-13.3.0/include/c++/13.3.0/bits/stl_algobase.h:506)
[#15] std::__copy_move_a1<…> (/data/opt/gcc-13.3.0/include/c++/13.3.0/bits/stl_algobase.h:533)
[#16] std::__copy_move_a<…> (/data/opt/gcc-13.3.0/include/c++/13.3.0/bits/stl_algobase.h:543)
[#17] std::copy<…> (/data/opt/gcc-13.3.0/include/c++/13.3.0/bits/stl_algobase.h:633)
[#18] main (ip_allocator.cpp:231)
I did a little research and found safe mode isn't compatible with shared memory scenario, particularly in persistence situation, because the absolute pointer address is written into the mmap file ? If so, it will definitely have issue when restart.
I've tried to remove BOOST_MULTI_INDEX_ENABLE_SAFE_MODE in ip_allocator.cpp, and it works in debug build.
Hi. I seem to have found a minor bug in ip_allocator example.
In debug mode (boost 1.90), I start the program in linux, insert one book record, then exit.
I start again and try to show the previous record and it just crashed.
Here's the backtrace:
I did a little research and found safe mode isn't compatible with shared memory scenario, particularly in persistence situation, because the absolute pointer address is written into the mmap file ? If so, it will definitely have issue when restart.
I've tried to remove
BOOST_MULTI_INDEX_ENABLE_SAFE_MODEin ip_allocator.cpp, and it works in debug build.