Boost C++ Libraries: Ticket #8945: managed_shared_memory::find assertion https://svn.boost.org/trac10/ticket/8945 <p> Hi, </p> <p> I am using ubuntu 13.04 and the compilator is : g++ (<a class="missing wiki">Ubuntu/Linaro</a> 4.6.3-1ubuntu5) 4.6.3 I have an application which successfully opened a shared memory (I checked with another client). The problem is, when a client of this shared memory tried to connect, the managed_shared_memory::find is blocking or throw the following error message (I don't know what cause my program to have one of this error rather than the other) : </p> <p> <em>mosaique: /usr/local/include/boost/interprocess/segment_manager.hpp:871: void* boost::interprocess::segment_manager::priv_generic_find(const CharT*, <a class="missing wiki">IndexType</a> &gt;&amp;, boost::interprocess::ipcdetail::in_place_interface&amp;, boost::interprocess::segment_manager::size_type&amp;, boost::interprocess::ipcdetail::true_, bool) [with CharT = char, <a class="missing wiki">CharType</a> = char, <a class="missing wiki">MemoryAlgorithm</a> = boost::interprocess::rbtree_best_fit, <a class="missing wiki">IndexType</a> = boost::interprocess::iset_index, boost::interprocess::segment_manager::size_type = long unsigned int, boost::interprocess::ipcdetail::true_ = boost::interprocess::ipcdetail::bool_]: Assertion `(ctrl_data-&gt;m_value_bytes % table.size) == 0' failed. Aborted (core dumped)</em> </p> <p> The size of my shared memory is : 9 953 280 Please help me fix this bug. </p> <p> The sources : The server is managed in the main_shm_server.cpp file The buggy client is main_mosaique.cpp It use the class SHMClient which is where the problem occur. The strange thing is when I use the same class with the same constructor parameter in another program, it is working. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8945 Trac 1.4.3 bersac_1@… Wed, 31 Jul 2013 09:01:04 GMT attachment set https://svn.boost.org/trac10/ticket/8945 https://svn.boost.org/trac10/ticket/8945 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_interprocess_test.zip</span> </li> </ul> <p> The sources of the bug. Focus on the two main and SHMClient </p> Ticket Ion Gaztañaga Tue, 15 Oct 2013 20:15:10 GMT <link>https://svn.boost.org/trac10/ticket/8945#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8945#comment:1</guid> <description> <p> Sorry for the long delay. I can't see anything in the code that could justify the assertion, but I can't reproduce it due to system dependencies. Could you simplify the code to ease the bug detection? Have you already solved the issue? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 03 Apr 2015 11:53:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8945#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8945#comment:2</guid> <description> <p> I have uncovered a similar problem: two programs using the same code behave differently. I need to bisect my recent changes but all was working perfectly for months with the same unit tests. What does this assertion mean? </p> </description> <category>Ticket</category> </item> <item> <author>datalligator@…</author> <pubDate>Fri, 03 Apr 2015 11:53:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8945#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8945#comment:2</guid> <description> <p> I have uncovered a similar problem: two programs using the same code behave differently. I need to bisect my recent changes but all was working perfectly for months with the same unit tests. What does this assertion mean? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 03 Apr 2015 12:27:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8945#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8945#comment:3</guid> <description> <p> Actually I haven't used this function until recently. Do get hangs or assertion failures tho'. I'll investigate further. </p> </description> <category>Ticket</category> </item> <item> <author>datalligator@…</author> <pubDate>Fri, 03 Apr 2015 14:04:19 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8945#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8945#comment:4</guid> <description> <p> Well there's something dodgy going on -- I've worked around it in my code -- actually resulting in an improvement to performance: I get all the named objects and use find_or_construct instead when I map the shared_memory and cache the pointers... (memory mapped file BTW). I'll try and produce a small program that reproduces the "find" problem. It's a bit suspect tho' so I might implement this function lower down in my implementation template class -- I can't believe it doesn't work. I'll compare the code for find_or_construct also. </p> </description> <category>Ticket</category> </item> <item> <author>imak@…</author> <pubDate>Sat, 25 Apr 2015 23:31:49 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/8945 https://svn.boost.org/trac10/ticket/8945 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">trace.txt</span> </li> </ul> <p> stack trace deadlock </p> Ticket imak@… Sat, 25 Apr 2015 23:32:23 GMT attachment set https://svn.boost.org/trac10/ticket/8945 https://svn.boost.org/trac10/ticket/8945 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">trace.2.txt</span> </li> </ul> <p> stack trace deadlock </p> Ticket imak@… Sat, 25 Apr 2015 23:32:33 GMT attachment set https://svn.boost.org/trac10/ticket/8945 https://svn.boost.org/trac10/ticket/8945 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">trace.3.txt</span> </li> </ul> <p> stack trace deadlock </p> Ticket imak@… Sat, 25 Apr 2015 23:33:36 GMT attachment set https://svn.boost.org/trac10/ticket/8945 https://svn.boost.org/trac10/ticket/8945 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">trace.4.txt</span> </li> </ul> <p> stack trace deadlock </p> Ticket imak@… Sat, 25 Apr 2015 23:38:50 GMT <link>https://svn.boost.org/trac10/ticket/8945#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8945#comment:5</guid> <description> <p> I had a similar problem on Windows. The first thing my program does is to open an existing segment and call find, it is quite simple. In one of many runs, it hit the exact same assertion. Then in every subsequent run, it locked on find. I replaced find with find_or_construct, and it kept locking - same behaviour. Unfortunately, this is system dependent and I can no longer reproduce it. I kept a stack trace though. This is where it locked, with find_or_construct. [my apologies the multiple attachments - my browser kept crashing too...] </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 12 Feb 2016 05:32:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8945#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8945#comment:6</guid> <description> <p> I can reproduce this issue consistently on CentOS 6.3 and 6.4 with Boost 1.59. Here's a program that exhibits such behavior (notice the type mismatch between <code>construct</code> and <code>find</code>): </p> <pre class="wiki">#include &lt;boost/interprocess/managed_shared_memory.hpp&gt; int main() { using namespace boost::interprocess; auto segment = managed_shared_memory(open_or_create, "my_segment", 4096); segment.construct&lt;char&gt;("key")(); segment.find&lt;int&gt;("key"); } </pre><p> On the first run, it crashes with: </p> <p> <em>/redacted/boost/interprocess/segment_manager.hpp:861:void* boost::interprocess::segment_manager&lt;<a class="missing wiki">CharType</a>, <a class="missing wiki">MemoryAlgorithm</a>, <a class="missing wiki">IndexType</a>&gt;::priv_generic_find(const CharT*, <a class="missing wiki">IndexType</a>&lt;boost::interprocess::ipcdetail::index_config&lt;CharT, MemoryAlgorithm&gt; &gt;&amp;, boost::interprocess::ipcdetail::in_place_interface&amp;, boost::interprocess::segment_manager&lt;<a class="missing wiki">CharType</a>, <a class="missing wiki">MemoryAlgorithm</a>, <a class="missing wiki">IndexType</a>&gt;::size_type&amp;, boost::interprocess::ipcdetail::true_, bool) [with CharT = char; <a class="missing wiki">CharType</a> = char; <a class="missing wiki">MemoryAlgorithm</a> = boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family&gt;; <a class="missing wiki">IndexType</a> = boost::interprocess::iset_index; boost::interprocess::segment_manager&lt;<a class="missing wiki">CharType</a>, <a class="missing wiki">MemoryAlgorithm</a>, <a class="missing wiki">IndexType</a>&gt;::size_type = long unsigned int; boost::interprocess::ipcdetail::true_ = boost::interprocess::ipcdetail::bool_&lt;true&gt;]: Assertion `(ctrl_data-&gt;m_value_bytes % table.size) == 0' failed. Aborted (core dumped) </em> </p> <p> On the second run, it deadlocks with the following <code>strace</code> output: </p> <pre class="wiki">open("/dev/shm/my_segment", O_RDWR|O_NOFOLLOW|O_CLOEXEC) = 3 fcntl(3, F_GETFD) = 0x1 (flags FD_CLOEXEC) fstat(3, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 fstat(3, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x7f1ae837e000 close(3) = 0 futex(0x7f1ae837e070, FUTEX_WAIT, 2, NULL </pre> </description> <category>Ticket</category> </item> </channel> </rss>