Boost C++ Libraries: Ticket #10581: Conflict when using boost::interprocess objects when linking to 2 different boost versions https://svn.boost.org/trac10/ticket/10581 <p> <strong>Introduction</strong>: Boost interprocess directory and file naming has changed after boost 1.54. Intreprocess communication does not work between version greater than 1.54 and lower than 1.54. Related bug report: <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/9767"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/9767</a> </p> <p> <strong>The Scenario</strong>: Compile a .dll that uses some shared memory object from the boost::interprocess library with version 1.55. (Think of this as an external 3rd party dll which you have no control over). Then make another project, using an older version of boost, lets say boost 1.51. In the new project, open a shared memory object, then call a function from the dll that also opens a shared memory object. This should have opened 2 shared memory objects, one with the 1.55 version and one with the 1.51 version. </p> <p> The problem is that the second memory object will always fail (even if you change the order). </p> <p> <strong>The Problem</strong>: Boost uses a singleton object to map the open interprocess memory objects. Because of the versions mismatch, the first shared memory object that is created, also creates the map (And with it the file naming convention). </p> <p> <strong>Solution</strong>: The singleton <strong>should</strong> just map the items, but use the functions according to the calling binary and compiled version of the caller. </p> <p> <strong>Workaround</strong>: I've just changed the names in the singleton object. I figured you can't have redundancy if it's incompatible, so lets have a separate memory mapping. In windows_intermodule_singleton.hpp changing the windows_semaphore_based_map named objects for the 1.55 version will keep the map separated. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10581 Trac 1.4.3 anonymous Sat, 11 Oct 2014 17:54:29 GMT <link>https://svn.boost.org/trac10/ticket/10581#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10581#comment:1</guid> <description> <p> But isn't just a problem of file naming convention ? Technically you can specify the name of the shared object ... and it's not decorated at all by boost. Could you give me an example ... isn't just because you changed compiler between both and allocate string instead of array of char ? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Yochai Timmer</dc:creator> <pubDate>Fri, 24 Oct 2014 08:33:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10581#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10581#comment:2</guid> <description> <p> The folder name is different, and in the older versions the file name was decorated by boost. </p> <p> Create 2 projects, a DLL and an executable. Link one project to boost 1.54 or older (i used 1.51), and the other to boost 1.55. </p> <p> Then use the exact same code (different classes for a different name, the fact that you cant use the same shared memory object is another issue). </p> <pre class="wiki">//in Dll1 struct Test1 { static void OpenSharedMemory() { boost::interprocess::message_queue sh(boost::interprocess::open_or_create, "Test1", 20,24); } } //in The executable struct Test2 { static void OpenSharedMemory() { boost::interprocess::message_queue sh(boost::interprocess::open_or_create, "Test2", 20,24); } } </pre><p> Now call them in the main function, the second call will always fail (you can change the order). </p> <pre class="wiki">int main(int argc, char* argv[]) { Test1::OpenSharedMemory(); Test2::OpenSharedMemory(); return 0; } </pre> </description> <category>Ticket</category> </item> </channel> </rss>