Boost C++ Libraries: Ticket #5230: Interprocess shared memory between 32 and 64 bit processes https://svn.boost.org/trac10/ticket/5230 <p> For sharing memory between 32 and 64 bit processes, all structures in shared memory must have the same binary layout with matching size_type and difference_type. In addition, offset_ptr must be 64bit in this case. </p> <p> This is a patch that parameterizes offset_ptr to explicitly accept its difference_type along with its internal offset_type. This difference_type (and the according size_type) is propagated to all other affected structures (memory algorithms, allocators, containers, ...). In 32/64 bit shared environments, difference_type should be set to <code>int</code> and offset_type to <code>unsigned __int64</code>. The default values are <code>ptrdiff_t</code> and <code>size_t</code>. </p> <p> Note: rbtree_best_fit also uses offset_type to store its internal block sizes, because these need to wrap-around correctly on 64bit machines. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5230 Trac 1.4.3 tgermer@… Fri, 25 Feb 2011 13:49:55 GMT attachment set https://svn.boost.org/trac10/ticket/5230 https://svn.boost.org/trac10/ticket/5230 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_interprocess_32_64bit_patch.zip</span> </li> </ul> Ticket Ion Gaztañaga Mon, 28 Feb 2011 10:14:33 GMT <link>https://svn.boost.org/trac10/ticket/5230#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:1</guid> <description> <p> Thanks, I've merged the patch with my latest local changes and I'm reviewing it. Regarding rbtree_best_fit's usage of offset_type, I think I will remove it. That might cause a binary incompatibility with earlier versions, but wrap-around logic is not needed to allocate memory correctly and increases bookeeping overhead for all allocations. I think I can easily remove this need in a day or two. </p> <p> I hope I'll review the patch and push it into trunk this week. Best. </p> </description> <category>Ticket</category> </item> <item> <author>tgermer@…</author> <pubDate>Mon, 28 Feb 2011 17:36:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:2</guid> <description> <p> I'm sorry, I found a bug in my patch at the selector that gets the offset_type for rbtree_best_fit. (I forgot a template parameter.) This should read: </p> <pre class="wiki"> template&lt;class S, class T&gt; struct ptr_size_type_selector&lt;boost::interprocess::offset_ptr&lt;void, S, T&gt; &gt; { typedef typename boost::interprocess::offset_ptr&lt;void, S, T&gt;::offset_type type; }; </pre><p> But this will get removed anyway, once we don't rely on wrap-around logic anymore... </p> <p> Best, Tobias </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Mon, 21 Mar 2011 15:25:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:3</guid> <description> <p> Please check latest SVN trunk code. Download both Move and Interprocess (new Intrusive is optional). There is one thing left, though: I can't make boost::aligned_storage work with offset_ptr and boost 1.47 in msvc (some namespace clashing when compiling). I hope you can find a workaround faster than me. Let me know if this version makes 32-64 bit process communication possible. </p> </description> <category>Ticket</category> </item> <item> <author>tgermer@…</author> <pubDate>Mon, 21 Mar 2011 16:20:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:4</guid> <description> <p> Thank you for integrating the patch. </p> <p> I also encountered this namespace conflict. It results from the ambiguity between "boost::detail" and "boost::interprocess::detail" when referring to "detail::" at the local namespace. I resolved this by declaring the absolute namespace path in aligned_storage.hpp. So every "detail::" becomes "::boost::detail::", which removes this ambiguity. This was also included in the patch. Is this change not feasible? </p> <p> We need some time to integrate the new version into our framework and test it. I'll post if it worked. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Mon, 21 Mar 2011 21:42:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:5</guid> <description> <p> Modifying aligned_storage is not in my hand, I think you should post this patch in the mailing list. If no one replies or has any solid arguments against the patch I will apply it. </p> </description> <category>Ticket</category> </item> <item> <author>tgermer@…</author> <pubDate>Tue, 22 Mar 2011 10:46:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:6</guid> <description> <p> OK, I just posted the patch to the mailing list (waiting for moderation). </p> <p> I also updated our boost libraries and tested the new version in our 32-64 bit mixed environment, and it works like a charm :) Thanks again for your effort! </p> </description> <category>Ticket</category> </item> <item> <author>xijing dai <dxj19831029@…></author> <pubDate>Wed, 23 Mar 2011 05:25:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:7</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:6" title="Comment 6">tgermer@…</a>: </p> <blockquote class="citation"> <p> OK, I just posted the patch to the mailing list (waiting for moderation). </p> <p> I also updated our boost libraries and tested the new version in our 32-64 bit mixed environment, and it works like a charm :) Thanks again for your effort! </p> </blockquote> <p> hey, </p> <p> I am currently on version 1.46.1 I would like to get this patch and have a go, is that possible? where can i get the patch? do i need to upgrade all my boost libs to trunk head in order to use it? </p> <p> Cheers </p> </description> <category>Ticket</category> </item> <item> <author>tgermer@…</author> <pubDate>Wed, 23 Mar 2011 08:08:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:8</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:7" title="Comment 7">xijing dai &lt;dxj19831029@…&gt;</a>: </p> <blockquote class="citation"> <p> I am currently on version 1.46.1 I would like to get this patch and have a go, is that possible? where can i get the patch? do i need to upgrade all my boost libs to trunk head in order to use it? </p> </blockquote> <p> I'm also on 1.46.1. You just have to update boost/interprocess, boost/intrusive and boost/move (which is new) to the trunk version in order to use it. No need to update anything else yet. Currently there is one open issue to make it work: the namespace conflict. If you want to resolve it manually, you need to remove the comment from "union internal_type" in boost/interprocess/offset_ptr.hpp. Then you have to replace every "detail::" with "::boost::detail::" in aligned_storage.hpp (the patch that I suggested in comment 4 and also on the mailing list). </p> </description> <category>Ticket</category> </item> <item> <author>xijing dai <dxj19831029@…></author> <pubDate>Wed, 23 Mar 2011 14:16:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:9</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:8" title="Comment 8">tgermer@…</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:7" title="Comment 7">xijing dai &lt;dxj19831029@…&gt;</a>: </p> <blockquote class="citation"> <p> I am currently on version 1.46.1 I would like to get this patch and have a go, is that possible? where can i get the patch? do i need to upgrade all my boost libs to trunk head in order to use it? </p> </blockquote> <p> I'm also on 1.46.1. You just have to update boost/interprocess, boost/intrusive and boost/move (which is new) to the trunk version in order to use it. No need to update anything else yet. Currently there is one open issue to make it work: the namespace conflict. If you want to resolve it manually, you need to remove the comment from "union internal_type" in boost/interprocess/offset_ptr.hpp. Then you have to replace every "detail::" with "::boost::detail::" in aligned_storage.hpp (the patch that I suggested in comment 4 and also on the mailing list). </p> </blockquote> <p> First all, thanks to this patch, whoever did it, I really appreciate their work, it helps me a lot. </p> <p> I tested in my application, it works great. testing includes: </p> <ul><li>windows_shared_memory </li><li>message queue </li><li>managed_windows_shared_memory </li></ul><p> <strong> create named item </strong> raw allocate </p> <p> By the way, I didn't change anything relating to the namespace issue, it passed compiling and worked great. </p> </description> <category>Ticket</category> </item> <item> <author>xijing dai <dxj19831029@…></author> <pubDate>Mon, 28 Mar 2011 03:27:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:10</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:9" title="Comment 9">xijing dai &lt;dxj19831029@…&gt;</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:8" title="Comment 8">tgermer@…</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:7" title="Comment 7">xijing dai &lt;dxj19831029@…&gt;</a>: </p> <blockquote class="citation"> <p> I am currently on version 1.46.1 I would like to get this patch and have a go, is that possible? where can i get the patch? do i need to upgrade all my boost libs to trunk head in order to use it? </p> </blockquote> <p> I'm also on 1.46.1. You just have to update boost/interprocess, boost/intrusive and boost/move (which is new) to the trunk version in order to use it. No need to update anything else yet. Currently there is one open issue to make it work: the namespace conflict. If you want to resolve it manually, you need to remove the comment from "union internal_type" in boost/interprocess/offset_ptr.hpp. Then you have to replace every "detail::" with "::boost::detail::" in aligned_storage.hpp (the patch that I suggested in comment 4 and also on the mailing list). </p> </blockquote> <p> First all, thanks to this patch, whoever did it, I really appreciate their work, it helps me a lot. </p> <p> I tested in my application, it works great. testing includes: </p> <ul><li>windows_shared_memory </li><li>message queue </li><li>managed_windows_shared_memory </li></ul><p> <strong> create named item </strong> raw allocate </p> <p> By the way, I didn't change anything relating to the namespace issue, it passed compiling and worked great. </p> </blockquote> <p> Interesting, I am not sure if I had wrong testing last week, or I did something wrong this week. </p> <p> This week, the program doesn't work properly between 32/64 managed_windows_shared_memory </p> <p> I do a little trace, when i allocate 1000000 bytes, it said free memory is: 999912, in 32bit. in 64 bit, it is: 999848. </p> <p> For me, it looks like something wrong in: rbtree_best_fit, since when i trace from get_free_memory method, it gives different values, so I assume there is some setting wrong for that class. </p> <p> by the way, I do uncomment union internal_type section, and I didn't change "detail::" stuff inside aligned_storage.hpp, is that a problem? </p> <p> Do you have any idea what's going on here? </p> <p> Cheers </p> </description> <category>Ticket</category> </item> <item> <author>tgermer@…</author> <pubDate>Mon, 28 Mar 2011 07:34:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:11</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:10" title="Comment 10">xijing dai &lt;dxj19831029@…&gt;</a>: </p> <blockquote class="citation"> <p> by the way, I do uncomment union internal_type section, and I didn't change "detail::" stuff inside aligned_storage.hpp, is that a problem? </p> </blockquote> <p> No, if your compiler doesn't produce an error, then this should be OK. </p> <blockquote class="citation"> <p> Do you have any idea what's going on here? </p> </blockquote> <p> Not really. Certainly Ion knows the details better and can tell what's going on. You could also look into raw memory and watch for inconsistencies across 32/64-bit builds. </p> </description> <category>Ticket</category> </item> <item> <author>tgermer@…</author> <pubDate>Mon, 28 Mar 2011 07:50:28 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/5230 https://svn.boost.org/trac10/ticket/5230 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_r70306_aligned_storage.zip</span> </li> </ul> <p> aligned-storage-patch </p> Ticket tgermer@… Mon, 28 Mar 2011 07:52:06 GMT <link>https://svn.boost.org/trac10/ticket/5230#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:12</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:5" title="Comment 5">igaztanaga</a>: </p> <blockquote class="citation"> <p> Modifying aligned_storage is not in my hand, I think you should post this patch in the mailing list. If no one replies or has any solid arguments against the patch I will apply it. </p> </blockquote> <p> @Ion: The guys on the mailing list just found an error with a digraph that I mistankingly had in the patch. In the last couple of days, there were no further replies. I think you could apply the patch. </p> <p> I added the patch as an attachment to this ticket. Interestingly, trac doesn't accept the patch as plain text and thinks it is spam :) </p> </description> <category>Ticket</category> </item> <item> <author>xijing dai <dxj19831029@…></author> <pubDate>Mon, 28 Mar 2011 08:05:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:13</guid> <description> <p> here is the code: </p> <pre class="wiki">this-&gt;memorySegment = new boost::interprocess::managed_windows_shared_memory( boost::interprocess::open_or_create, name, size); int sizeB = this-&gt;memorySegment-&gt;get_free_memory(); </pre><p> i allocate 1000000 bytes, it said free memory is: 999912, in 32bit. in 64 bit, it is: 999848. </p> <p> Just wonder, do I need to use different namespace or class name in order for managed shared memory to be compatible for 32 and 64 system? </p> <p> emm...by the way, how can i reach Ion? </p> <p> Cheers </p> </description> <category>Ticket</category> </item> <item> <author>tgermer@…</author> <pubDate>Mon, 28 Mar 2011 08:11:07 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:14</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:13" title="Comment 13">xijing dai &lt;dxj19831029@…&gt;</a>: </p> <blockquote class="citation"> <p> Just wonder, do I need to use different namespace or class name in order for managed shared memory to be compatible for 32 and 64 system? </p> </blockquote> <p> No. In our case, the code for the 32 and 64 bit processes is actually identical. </p> <blockquote class="citation"> <p> emm...by the way, how can i reach Ion? </p> </blockquote> <p> Well, I think he follows this conversation :) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Mon, 28 Mar 2011 08:42:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:15</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:13" title="Comment 13">xijing dai &lt;dxj19831029@…&gt;</a>: </p> <blockquote class="citation"> <p> here is the code: </p> </blockquote> <p> The patch is not about making all interprocess classes workable between 32 and 64 bit applications. Is about customizing offset_ptr and propagate its attributes (size_type, difference_type, etc..) so that that this *could* be possible, of course depending on the compiler ABI of 32/64 bit applications. The patch is experimental, so it won't be documented and made official until it gets some real-application experience. </p> <p> Regarding message_queue, it is a bug that it does not work between 32 and 64 bit applications. I should change queue internals to make internal types fixed length. It's in my to-do list but i haven't found time to implement it. </p> </description> <category>Ticket</category> </item> <item> <author>xijing dai <dxj19831029@…></author> <pubDate>Mon, 28 Mar 2011 10:14:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:16</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:15" title="Comment 15">igaztanaga</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:13" title="Comment 13">xijing dai &lt;dxj19831029@…&gt;</a>: </p> <blockquote class="citation"> <p> here is the code: </p> </blockquote> <p> The patch is not about making all interprocess classes workable between 32 and 64 bit applications. Is about customizing offset_ptr and propagate its attributes (size_type, difference_type, etc..) so that that this *could* be possible, of course depending on the compiler ABI of 32/64 bit applications. The patch is experimental, so it won't be documented and made official until it gets some real-application experience. </p> <p> Regarding message_queue, it is a bug that it does not work between 32 and 64 bit applications. I should change queue internals to make internal types fixed length. It's in my to-do list but i haven't found time to implement it. </p> </blockquote> <p> got u! </p> <p> which class have u tested? let me check if I can replace with them. </p> <p> otherwise, I am not sure if we could wait for next boost release, I need to think some backup plans. :) </p> </description> <category>Ticket</category> </item> <item> <author>xijing dai <dxj19831029@…></author> <pubDate>Mon, 28 Mar 2011 13:02:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:17 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:17</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:15" title="Comment 15">igaztanaga</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:13" title="Comment 13">xijing dai &lt;dxj19831029@…&gt;</a>: </p> <blockquote class="citation"> <p> here is the code: </p> </blockquote> <p> The patch is not about making all interprocess classes workable between 32 and 64 bit applications. Is about customizing offset_ptr and propagate its attributes (size_type, difference_type, etc..) so that that this *could* be possible, of course depending on the compiler ABI of 32/64 bit applications. The patch is experimental, so it won't be documented and made official until it gets some real-application experience. </p> <p> Regarding message_queue, it is a bug that it does not work between 32 and 64 bit applications. I should change queue internals to make internal types fixed length. It's in my to-do list but i haven't found time to implement it. </p> </blockquote> <p> boost::interprocess::offset_ptr&lt;void&gt; is 4 bytes long, is that normal for 32 program? should it be 8 bytes? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 28 Mar 2011 13:11:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5230#comment:18 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:18</guid> <description> <p> offset_ptr uses its template parameter <code>OffsetType</code> for its internal representation. That means it depends on you how large it is. Per default, <code>OffsetType=size_t</code>, which is 4 bytes for 32 bit programs. In 32/64-bit mixed applications, you should indeed take an 8-byte offset_ptr, for example: <code>offset_ptr&lt;void, int, unsigned long long&gt; </code> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Fri, 01 Apr 2011 21:14:05 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5230#comment:19 https://svn.boost.org/trac10/ticket/5230#comment:19 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed for Boost 1.47 </p> Ticket anonymous Tue, 07 Feb 2012 01:30:12 GMT <link>https://svn.boost.org/trac10/ticket/5230#comment:20 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5230#comment:20</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/5230#comment:19" title="Comment 19">igaztanaga</a>: </p> <blockquote class="citation"> <p> Fixed for Boost 1.47 </p> </blockquote> <p> According to the 1.48.0 release notes, this bug fix went into 1.48.0, not 1.47. (See <a href="http://www.boost.org/users/history/version_1_48_0.html">http://www.boost.org/users/history/version_1_48_0.html</a> ) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 30 Aug 2017 12:25:51 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/5230#comment:21 https://svn.boost.org/trac10/ticket/5230#comment:21 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> Ticket