boost::flyweights::intermodule_holder 初始化失败,出现 interprocess_exception 且权限被拒绝

问题描述 投票:0回答:1

我不知道为什么会失败。 共享内存对象应该是唯一的,因为它只能从同一进程内访问。

当前目录可写,$TMPDIR 也可写,/tmp/ 也可写

这是堆栈跟踪:

Catchpoint 1 (exception thrown), __cxxabiv1::__cxa_throw (obj=0x99ca40,
    tinfo=0x946668 <typeinfo for boost::interprocess::interprocess_exception>,
    dest=0x5a0f8a <boost::interprocess::interprocess_exception::~interprocess_exception()>)
    at ../../../../gcc-5.3.0/libstdc++-v3/libsupc++/eh_throw.cc:62
(gdb) where
#0  __cxxabiv1::__cxa_throw (obj=0x99ca40, tinfo=0x946668 <typeinfo for boost::interprocess::interprocess_exception>,
    dest=0x5a0f8a <boost::interprocess::interprocess_exception::~interprocess_exception()>)
    at ../../../../gcc-5.3.0/libstdc++-v3/libsupc++/eh_throw.cc:62
#1  0x00000000005a5261 in boost::interprocess::shared_memory_object::priv_open_or_create<char> (this=0x7fffffffa200,
    type=boost::interprocess::ipcdetail::DoOpen, filename=0x99c930 "bip.gmem.map.44132_0.000000", mode=boost::interprocess::read_write,
    perm=...) at /mnt/share/boost/boost-1.80//include/boost/interprocess/shared_memory_object.hpp:425
#2  0x00000000005a1e7d in boost::interprocess::shared_memory_object::shared_memory_object (this=0x7fffffffa200,
    name=0x99c930 "bip.gmem.map.44132_0.000000", mode=boost::interprocess::read_write)
    at /mnt/share/boost/boost-1.80//include/boost/interprocess/shared_memory_object.hpp:84
#3  0x00000000005aa28b in boost::interprocess::ipcdetail::managed_open_or_create_impl<boost::interprocess::shared_memory_object, 16ul, true, false>::priv_open_or_create<char const*, boost::interprocess::ipcdetail::create_open_func<boost::interprocess::ipcdetail::basic_managed_memory_impl<char, boost::interprocess::rbtree_best_fit<boost::interprocess::ipcdetail::intermodule_singleton_mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index, 16ul> > > (this=0x7fffffffa3d8,
    type=boost::interprocess::ipcdetail::DoOpen, id=@0x7fffffffa340: 0x99c930 "bip.gmem.map.44132_0.000000", size=0,
    mode=boost::interprocess::read_write, addr=0x0, perm=..., construct_func=...)
    at /mnt/share/boost/boost-1.80//include/boost/interprocess/detail/managed_open_or_create_impl.hpp:488
#4  0x00000000005a7630 in boost::interprocess::ipcdetail::managed_open_or_create_impl<boost::interprocess::shared_memory_object, 16ul, true, false>::managed_open_or_create_impl<char const*, boost::interprocess::ipcdetail::create_open_func<boost::interprocess::ipcdetail::basic_managed_memory_impl<char, boost::interprocess::rbtree_best_fit<boost::interprocess::ipcdetail::intermodule_singleton_mutex_family, boost::interprocess::offset_ptr<void, long, unsigned long, 0ul>, 0ul>, boost::interprocess::iset_index, 16ul> > > (this=0x7fffffffa3d8,
    id=@0x7fffffffa340: 0x99c930 "bip.gmem.map.44132_0.000000", mode=boost::interprocess::read_write, addr=0x0, construct_func=...)
    at /mnt/share/boost/boost-1.80//include/boost/interprocess/detail/managed_open_or_create_impl.hpp:179
#5  0x00000000005a552a in boost::interprocess::ipcdetail::basic_managed_global_memory<boost::interprocess::shared_memory_object, true>::basic_managed_global_memory (this=0x7fffffffa3d0, name=0x99c930 "bip.gmem.map.44132_0.000000", addr=0x0)
    at /mnt/share/boost/boost-1.80//include/boost/interprocess/detail/managed_global_memory.hpp:108
#6  0x00000000005a26bf in boost::interprocess::ipcdetail::intermodule_singleton_helpers::thread_safe_global_map_dependant<boost::interprocess::ipcdetail::basic_managed_global_memory<boost::interprocess::shared_memory_object, true> >::apply_gmem_erase_logic (
    filepath=0x99c8e0 "/tmp/boost_interprocess/gmem/lck44132_0.000000", filename=0x994923 "lck44132_0.000000")
    at /mnt/share/boost/boost-1.80//include/boost/interprocess/detail/portable_intermodule_singleton.hpp:171
#7  0x00000000005a57a8 in boost::interprocess::ipcdetail::for_each_file_in_dir<void (*)(char const*, char const*)> (
    dir=0x994840 "/tmp/boost_interprocess/gmem",
    f=0x5a25e7 <boost::interprocess::ipcdetail::intermodule_singleton_helpers::thread_safe_global_map_dependant<boost::interprocess::ipcdetail::basic_managed_global_memory<boost::interprocess::shared_memory_object, true> >::apply_gmem_erase_logic(char const*, char const*)>)
    at /mnt/share/boost/boost-1.80//include/boost/interprocess/detail/os_file_functions.hpp:804
#8  0x00000000005a283d in boost::interprocess::ipcdetail::intermodule_singleton_helpers::thread_safe_global_map_dependant<boost::interprocess::ipcdetail::basic_managed_global_memory<boost::interprocess::shared_memory_object, true> >::remove_old_gmem ()
    at /mnt/share/boost/boost-1.80//include/boost/interprocess/detail/portable_intermodule_singleton.hpp:198
#9  0x00000000005b9eab in boost::interprocess::ipcdetail::intermodule_singleton_common<boost::interprocess::ipcdetail::basic_managed_global_memory<boost::interprocess::shared_memory_object, true> >::initialize_global_map_handle ()
    at /mnt/share/boost/boost-1.80//include/boost/interprocess/detail/intermodule_singleton_common.hpp:237
#10 0x00000000005b588f in boost::interprocess::ipcdetail::intermodule_singleton_common<boost::interprocess::ipcdetail::basic_managed_global_memory<boost::interprocess::shared_memory_object, true> >::initialize_singleton_logic (ptr=@0x97ba80: 0x0,
    this_module_singleton_initialized=@0x97ba88: 1,
    constructor=0x5b59e7 <boost::interprocess::ipcdetail::intermodule_singleton_impl<boost::flyweights::detail::flyweight_core<boost::flyweights::detail::default_value_policy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, mpl_::na, boost::flyweights::refcounted, boost::flyweights::hashed_factory<mpl_::na, mpl_::na, mpl_::na, 0>, boost::flyweights::no_locking, boost::flyweights::intermodule_holder>::holder_arg, true, false, boost::interprocess::ipcdetail::basic_managed_global_memory<boost::interprocess::shared_memory_object, true> >::singleton_constructor(boost::interprocess::ipcdetail::basic_managed_global_memory<boost::interprocess::shared_memory_object, true>&)>, phoenix=false) at /mnt/share/boost/boost-1.80//include/boost/interprocess/detail/intermodule_singleton_common.hpp:127
#11 0x00000000005b21e2 in boost::interprocess::ipcdetail::intermodule_singleton_impl<boost::flyweights::detail::flyweight_core<boost::flyweights::detail::default_value_policy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, mpl_::na, boost::flyweights::refcounted, boost::flyweights::hashed_factory<mpl_::na, mpl_::na, mpl_::na, 0>, boost::flyweights::no_locking, boost::flyweights::intermodule_holder>::holder_arg, true, false, boost::interprocess::ipcdetail::basic_managed_global_memory<boost::interprocess::shared_memory_object, true> >::atentry_work () at /mnt/share/boost/boost-1.80//include/boost/interprocess/detail/intermodule_singleton_common.hpp:345
#12 0x00000000005aee02 in boost::interprocess::ipcdetail::intermodule_singleton_impl<boost::flyweights::detail::flyweight_core<boost::flyweights::detail::default_value_policy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, mpl_::na, boost::flyweights::refcounted, boost::flyweights::hashed_factory<mpl_::na, mpl_::na, mpl_::na, 0>, boost::flyweights::no_locking, boost::flyweights::intermodule_holder>::holder_arg, true, false, boost::interprocess::ipcdetail::basic_managed_global_memory<boost::interprocess::shared_memory_object, true> >::get () at /mnt/share/boost/boost-1.80//include/boost/interprocess/detail/intermodule_singleton_common.hpp:335
#13 0x00000000005aaf81 in boost::flyweights::detail::flyweight_core<boost::flyweights::detail::default_value_policy<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, mpl_::na, boost::flyweights::refcounted, boost::flyweights::hashed_factory<mpl_::na, mpl_::na, mpl_::na, 0>, boost::flyweights::no_locking, boost::flyweights::intermodule_holder>::init ()
    at /mnt/share/boost/boost-1.80//include/boost/flyweight/detail/flyweight_core.hpp:112
#14 0x000000000059de56 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535)
    at /mnt/share/boost/boost-1.80//include/boost/flyweight/detail/flyweight_core.hpp:278
#15 0x000000000059f46b in _GLOBAL__sub_I_messagehandler.cc(void) () at src/framework/src/messagehandler.cc:2516
#16 0x00000000007fe79d in __libc_csu_init ()
#17 0x00002aaaabbbf4e5 in __libc_start_main () from /lib64/libc.so.6
#18 0x00000000005901ae in _start ()

有问题的文件

/tmp/boost_interprocess/gmem/lck44132_0.000000
(显示在堆栈跟踪中)属于另一个用户。可能是进程 ID 已重新启动的情况。但文件名中记录的数字与进程ID 38193不匹配。

c++ c++14 centos7 boost-interprocess boost-flyweight
1个回答
0
投票

问题是相关进程可能会崩溃或被杀死。由于 LINUX 上没有结构化信号处理,因此在这种情况下我们无能为力。因此,该库创建的文件(共享内存段)可能会留在系统中,并导致后续进程(来自另一个用户)失败。另一个问题当然是共享内存对象即使没有进程打开它也会持续存在。

© www.soinside.com 2019 - 2024. All rights reserved.