Boost C++ Libraries: Ticket #12659: Deadlocked with boost::interprocess::managed_mapped_file find https://svn.boost.org/trac10/ticket/12659 <p> Scenario : I have a existing file which at first is opened &amp; loaded using </p> <pre class="wiki">m_file.reset(new boost::interprocess::managed_mapped_file(boost::interprocess::open_or_create, file_name.c_str(), m_size)); </pre><p> then I am using find member function </p> <pre class="wiki">Type *vect = m_file-&gt;find&lt;Type&gt;(key).first; </pre><p> Here my code halts(deadlock). </p> <pre class="wiki">boost::interprocess::ipcdetail::posix_recursive_mutex::lock (this=0x7ffff572d070) at /home/dev/build/third_party/64-rhel5/boost_1_59_0/include/boost/interprocess/sync/posix/recursive_mutex.hpp:90 90 if (pthread_mutex_lock(&amp;m_mut) != 0) (gdb) p m_mut $1 = {__data = {__lock = 2, __count = 1, __owner = **16792**, __nusers = 1, __kind = 129, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = "\002\000\000\000\001\000\000\000\230A\000\000\001\000\000\000\201", '\000' &lt;repeats 22 times&gt;, __align = 4294967298} (gdb) info threads all 4 Thread 0x7ffff6af0700 (LWP 23305) 0x00000038dceac6aa in times () from /lib64/libc.so.6 3 Thread 0x7ffff75dd700 (LWP 23304) 0x00000038dd20b68c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0 2 Thread 0x7ffff7fde700 (LWP 23303) 0x00000038dd20eca3 in recvfrom () from /lib64/libpthread.so.0 * 1 Thread 0x7ffff7fe27e0 (LWP 23300) boost::interprocess::ipcdetail::posix_recursive_mutex::lock (this=0x7ffff572d070) at /home/dev/build/third_party/64-rhel5/boost_1_59_0/include/boost/interprocess/sync/posix/recursive_mutex.hpp:90 </pre><p> If you see here onwer is 16792, but I don't see any such thread. </p> <p> Some more info. </p> <pre class="wiki"> p *mp_header ..... static PayloadPerAllocation = &lt;optimized out&gt;, m_header = {&lt;boost::interprocess::interprocess_recursive_mutex&gt; = {mutex = {m_mut = { __data = {__lock = 2, __count = 1, __owner = 16792, __nusers = 1, __kind = 129, __spins = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = "\002\000\000\000\001\000\000\000\230A\000\000\001\000\000\000\201", '\000' &lt;repeats 22 times&gt;, __align = 4294967298}}}, m_named_index = ..... </pre><p> previous mutex informations are still stored. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12659 Trac 1.4.3 John Maddock Thu, 29 Dec 2016 11:38:52 GMT component changed; owner set https://svn.boost.org/trac10/ticket/12659#comment:1 https://svn.boost.org/trac10/ticket/12659#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Ion Gaztañaga</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">interprocess</span> </li> </ul> Ticket Ion Gaztañaga Mon, 06 Feb 2017 13:20:02 GMT <link>https://svn.boost.org/trac10/ticket/12659#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12659#comment:2</guid> <description> <p> I can't reproduce the problem, could you provide a small compilable test case? </p> </description> <category>Ticket</category> </item> <item> <author>windjianlipf@…</author> <pubDate>Thu, 26 Jul 2018 08:38:37 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12659#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12659#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/12659#comment:2" title="Comment 2">Ion Gaztañaga</a>: </p> <blockquote class="citation"> <p> I can't reproduce the problem, could you provide a small compilable test case? </p> </blockquote> <p> I am suffering from this problem too. </p> <p> The code halts at the lock. </p> <pre class="wiki">(gdb) info threads Id Target Id Frame * 1 Thread 0x7ffff7fcb740 (LWP 15189) "test_mmap" __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135 (gdb) bt #0 __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135 #1 0x00007ffff7bc3e42 in __GI___pthread_mutex_lock (mutex=0x7ffff6df0070) at ../nptl/pthread_mutex_lock.c:115 #2 0x000000000040286f in boost::interprocess::ipcdetail::posix_recursive_mutex::lock (this=0x7ffff6df0070) at thirdparty/boost-1.66.0/include/boost/interprocess/sync/posix/recursive_mutex.hpp:90 #3 boost::interprocess::interprocess_recursive_mutex::lock (this=0x7ffff6df0070) at thirdparty/boost-1.66.0/include/boost/interprocess/sync/interprocess_recursive_mutex.hpp:163 #4 boost::interprocess::scoped_lock&lt;boost::interprocess::interprocess_recursive_mutex&gt;::lock (this=&lt;synthetic pointer&gt;) at thirdparty/boost-1.66.0/include/boost/interprocess/sync/scoped_lock.hpp:284 #5 boost::interprocess::segment_manager&lt;char, boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family, boost::interprocess::offset_ptr&lt;void, long, unsigned long, 0ul&gt;, 0ul&gt;, boost::interprocess::iset_index&gt;::priv_get_lock (use_lock=true, this=0x7ffff6df0010) at thirdparty/boost-1.66.0/include/boost/interprocess/segment_manager.hpp:1315 </pre><pre class="wiki">(gdb) f 1 #1 0x00007ffff7bc3e42 in __GI___pthread_mutex_lock (mutex=0x7ffff6df0070) at ../nptl/pthread_mutex_lock.c:115 115 ../nptl/pthread_mutex_lock.c: 没有那个文件或目录. (gdb) p *mutex $1 = {__data = {__lock = 2, __count = 2, __owner = 19759, __nusers = 1, __kind = 129, __spins = 0, __elision = 0, __list = { __prev = 0x0, __next = 0x0}}, __size = "\002\000\000\000\002\000\000\000/M\000\000\001\000\000\000\201", '\000' &lt;repeats 22 times&gt;, __align = 8589934594} </pre><p> It's a single-threaded program, however the mutex infomation shows the owner is 19759. </p> <p> I'm using boost-1.66.0. </p> <p> Here is my test code. The file exceeds the limit, Can I email you? </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;boost/interprocess/managed_mapped_file.hpp&gt; #include &lt;boost/interprocess/allocators/allocator.hpp&gt; #include &lt;boost/interprocess/containers/string.hpp&gt; namespace bip = ::boost::interprocess; using SegmentManager = bip::managed_mapped_file::segment_manager; using Allocator = bip::allocator&lt;char, SegmentManager&gt;; using String = bip::basic_string&lt;char, std::char_traits&lt;char&gt;, Allocator&gt;; int main() { auto segment = std::make_shared&lt;bip::managed_mapped_file&gt;( bip::open_or_create, "./test_mmap", 1024*1024*10); (*segment).template find&lt;String&gt;("test"); std::cout &lt;&lt; "find" &lt;&lt; std::endl; return 0; } </pre> </description> <category>Ticket</category> </item> </channel> </rss>