【问题标题】:exception in boost:interprocess, shared memory object deletionboost中的异常:进程间,共享内存对象删除
【发布时间】:2016-02-04 16:57:56
【问题描述】:

我将一段简单的代码移至示例应用程序的主要功能,以避免影响任何其他应用程序部分:

    namespace bi = boost:interprocess;

    bi::shared_memory_object::remove("shm");
    bi::named_mutex::remove("mtx");
    bi::named_condition::remove("cnd");

只是第一行在内部 boost 进程间代码中引发了一个异常: 在 windows_intermodule_singleton.hpp, 118 (v 1.60.0) 粗线是它发生的地方。 Win64、VC v19、Windows 10

     ...
     caster.addr = m;
     BOOST_ASSERT((caster.addr_uint64 & boost::uint64_t(3)) == 0);
     max_count = boost::uint32_t(caster.addr_uint64 >> 32);
     **initial_count = boost::uint32_t(caster.addr_uint64);**
     initial_count = initial_count/4;
     //Make sure top two bits are zero
     BOOST_ASSERT((max_count & boost::uint32_t(0xC0000000)) == 0);
     //Set quasi-top bit
     max_count |= boost::uint32_t(0x40000000);
     ...

知道为什么会这样吗?这可能与 x64 内存模型有关吗?

【问题讨论】:

    标签: c++ boost boost-interprocess


    【解决方案1】:

    这也不例外,我的疏忽, 使用所有 /RTC 编译器设置编译,这个地方看起来像潜在的数据丢失 (?) 8 字节到 4。 windbg 报告:_RTC_Check_8_to_4

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-13
      • 2011-03-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多