[Boost-bugs] [Boost C++ Libraries] #10180: shared_memory_object assertion when used with boost unit test

Subject: [Boost-bugs] [Boost C++ Libraries] #10180: shared_memory_object assertion when used with boost unit test
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-07-07 05:00:56

#10180: shared_memory_object assertion when used with boost unit test
 Reporter: andrew.lang@… | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.55.0
 Severity: Problem | Keywords:
 I am running with Visual Studio 2010, and boost 1.55.
 When I run a simple unit test with shared_memory_object, I get an
 assertion on shutdown.
 The test itself creates a shared memory object, maps it to memory, and
 writes to it; it then opens a shared memory object of the same name and
 reads from it. This works fine.

 On exit, the fini_atomic_func functor in intermodule_singleton_common is
 run to clean up. This does the following:
          ref_count_ptr *rcount =
          <ThreadSafeGlobalMap>::find(m_map, typeid(C).name());
          //The object must exist
 The assertion fails. In the debugger I can see that typeid(C).name() has
 returned a rubbish string, and therefore no map entry is found. When that
 same code is executed in init_atomic_func, typeid(C).name() returns
 "struct boost::interprocess::ipcdetail::windows_bootstamp" as expected.
 Following the relevant memory address in the debugger, I see that the
 typeid string is erased in the unit test's framework::shutdown() function.
 This is done deliberately to eliminate fake memory leak reports from the
 typeid strings. See boost\test\impl\framework.ipp.

 Unfortunately the interprocess cleanup is done via a handler registered
 with std::atexit, which guarantees it will be after framework has run
 shutdown. I don't see any options on either side (boost unit test or boost
 interprocess) which would allow the order to be fixed up.

 Simplest code to reproduce:
 #include <boost/test/unit_test.hpp>
 #include <boost/interprocess/shared_memory_object.hpp>
 namespace IP = boost::interprocess;

 BOOST_AUTO_TEST_SUITE( TestSharedMemory )
 BOOST_AUTO_TEST_CASE( CauseAssertionFailure )
    IP::shared_memory_object lShared( IP::open_only, "test_string",
 IP::read_only );
    BOOST_REQUIRE( lShared.get_name() != 0 );

Ticket URL: <https://svn.boost.org/trac/boost/ticket/10180>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC