Boost C++ Libraries: Ticket #5523: Crash with singleton_pool in multithreaded mode https://svn.boost.org/trac10/ticket/5523 <p> Hi, </p> <p> I am making calls to singleton_pool::ordered_malloc() with 2 different threads and the application is crashing. The code can be found here: <a class="ext-link" href="https://svn.boost.org/svn/boost/sandbox/block_ptr/libs/smart_ptr/example/thread_test.cpp"><span class="icon">​</span>https://svn.boost.org/svn/boost/sandbox/block_ptr/libs/smart_ptr/example/thread_test.cpp</a> </p> <p> And I get the following backtrace: </p> <p> <a class="missing ticket">#0</a> 0x0000000000407766 in boost::simple_segregated_storage&lt;unsigned long&gt;::try_malloc_n (start=@0x40a30dd0, n=10, partition_size=8) </p> <blockquote> <p> at /home/vnmr1/phil/boost_1_46_1/boost/pool/simple_segregated_storage.hpp:236 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> 0x000000000040781b in boost::simple_segregated_storage&lt;unsigned long&gt;::malloc_n (this=0x614ae8, n=11, partition_size=8) </p> <blockquote> <p> at /home/vnmr1/phil/boost_1_46_1/boost/pool/simple_segregated_storage.hpp:260 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a> 0x000000000040af4f in boost::pool&lt;boost::default_user_allocator_new_delete&gt;::ordered_malloc (this=0x614ae8, n=88) </p> <blockquote> <p> at /home/vnmr1/phil/boost_1_46_1/boost/pool/pool.hpp:527 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3" title="#3: Bugs: automatic conversion and overload proble (closed: fixed)">#3</a> 0x000000000040b392 in boost::singleton_pool&lt;boost::detail::sh::pool, 1u, boost::default_user_allocator_new_delete, boost::details::pool::pthread_mutex, 32u, 0u&gt;::ordered_malloc (n=88) </p> <blockquote> <p> at /home/vnmr1/phil/boost_1_46_1/boost/pool/singleton_pool.hpp:72 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4" title="#4: Bugs: any_ptr in any library documentation? (closed: Fixed)">#4</a> 0x000000000040d7ce in boost::detail::sh::pool::allocate (this=0x6148d0, </p> <blockquote> <p> s=88) at ../../../boost/detail/block_base.hpp:130 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5" title="#5: Bugs: shared_ptr and self-owning objects (closed: Fixed)">#5</a> 0x000000000040d83a in boost::detail::sh::block&lt;std::pair&lt;int, int&gt; &gt;::operator new (s=88) at ../../../boost/detail/block_base.hpp:271 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6" title="#6: Bugs: tie in utility.hpp and tuple.hpp clash. (closed: Duplicate)">#6</a> 0x000000000040d85d in boost::detail::sh::make_block&lt;std::pair&lt;int, int&gt;, std::pair&lt;int, int&gt; &gt; (t0=@0x40a31030) at ../../../boost/block_ptr.hpp:480 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7" title="#7: Bugs: g++ 2.96 requires NO_STRINGSTREAM (closed: Fixed)">#7</a> 0x0000000000405e97 in worker (id=0) at thread_test.cpp:17 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8" title="#8: Bugs: prop in undirected graph + out_edges (closed: Works For Me)">#8</a> 0x0000000000408a20 in boost::_bi::list1&lt;boost::_bi::value&lt;int&gt; &gt;::operator()&lt;void (*)(int), boost::_bi::list0&gt; (this=0x1a0cf5b0, f=@0x1a0cf5a8, </p> <blockquote> <p> a=@0x40a310cf) at /home/vnmr1/phil/boost_1_46_1/boost/bind/bind.hpp:253 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9" title="#9: Bugs: config_info ambiguity error (closed: Invalid)">#9</a> 0x0000000000408a5e in boost::_bi::bind_t&lt;void, void (*)(int), boost::_bi::list1&lt;boost::_bi::value&lt;int&gt; &gt; &gt;::operator() (this=0x1a0cf5a8) </p> <blockquote> <p> at /home/vnmr1/phil/boost_1_46_1/boost/bind/bind_template.hpp:20 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/10" title="#10: Bugs: allyourbase.jam file is bad. (closed: Out of Date)">#10</a> 0x0000000000408a7c in boost::detail::thread_data&lt;boost::_bi::bind_t&lt;void, void (*)(int), boost::_bi::list1&lt;boost::_bi::value&lt;int&gt; &gt; &gt; &gt;::run ( </p> <blockquote> <p> this=0x1a0cf420) at /home/vnmr1/phil/boost_1_46_1/boost/thread/detail/thread.hpp:61 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/11" title="#11: Bugs: why not using mt19937? (closed: Fixed)">#11</a> 0x00002b93700f9914 in thread_proxy () </p> <blockquote> <p> from /home/vnmr1/phil/lib/libboost_thread.so.1.46.1 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/12" title="#12: Bugs: Can't specify VertexPredicate (closed: Fixed)">#12</a> 0x0000003906a06367 in start_thread () from /lib64/libpthread.so.0 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/13" title="#13: Bugs: iterator_adapter and abstract classes (closed: Out of Date)">#13</a> 0x0000003905ed30ad in clone () from /lib64/libc.so.6 </p> <p> Thanks, -Phil </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5523 Trac 1.4.3 philippeb8@… Fri, 06 May 2011 07:00:30 GMT <link>https://svn.boost.org/trac10/ticket/5523#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5523#comment:1</guid> <description> <p> I added mutexes before the pool subroutines are called and I still get the crash. The new backtrace is: <a class="missing ticket">#0</a> 0x00000000004071a4 in boost::simple_segregated_storage&lt;unsigned long&gt;::try_malloc_n (start=@0x42555dc0, n=10, partition_size=8) </p> <blockquote> <p> at /home/vnmr1/phil/boost_1_46_1/boost/pool/simple_segregated_storage.hpp:236 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> 0x0000000000407259 in boost::simple_segregated_storage&lt;unsigned long&gt;::malloc_n (this=0x6136c8, n=11, partition_size=8) </p> <blockquote> <p> at /home/vnmr1/phil/boost_1_46_1/boost/pool/simple_segregated_storage.hpp:260 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a> 0x000000000040b3c3 in boost::pool&lt;boost::default_user_allocator_new_delete&gt;::ordered_malloc (this=0x6136c8, n=88) </p> <blockquote> <p> at /home/vnmr1/phil/boost_1_46_1/boost/pool/pool.hpp:527 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3" title="#3: Bugs: automatic conversion and overload proble (closed: fixed)">#3</a> 0x000000000040b87c in boost::singleton_pool&lt;boost::detail::sh::pool, 1u, boost::default_user_allocator_new_delete, boost::details::pool::pthread_mutex, 32u, 0u&gt;::ordered_malloc (n=88) </p> <blockquote> <p> at /home/vnmr1/phil/boost_1_46_1/boost/pool/singleton_pool.hpp:72 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4" title="#4: Bugs: any_ptr in any library documentation? (closed: Fixed)">#4</a> 0x000000000040cc7a in boost::detail::sh::pool::allocate (s=88) </p> <blockquote> <p> at ../../../boost/detail/block_base.hpp:131 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5" title="#5: Bugs: shared_ptr and self-owning objects (closed: Fixed)">#5</a> 0x000000000040cd09 in boost::detail::sh::block&lt;std::pair&lt;int, int&gt; &gt;::operator new (s=88) at ../../../boost/detail/block_base.hpp:274 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6" title="#6: Bugs: tie in utility.hpp and tuple.hpp clash. (closed: Duplicate)">#6</a> 0x000000000040cd2d in boost::detail::sh::make_block&lt;std::pair&lt;int, int&gt;, std::pair&lt;int, int&gt; &gt; (t0=@0x42556030) at ../../../boost/block_ptr.hpp:492 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7" title="#7: Bugs: g++ 2.96 requires NO_STRINGSTREAM (closed: Fixed)">#7</a> 0x00000000004059ff in worker (id=1) at thread_test.cpp:17 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8" title="#8: Bugs: prop in undirected graph + out_edges (closed: Works For Me)">#8</a> 0x00000000004083ba in boost::_bi::list1&lt;boost::_bi::value&lt;int&gt; &gt;::operator()&lt;void (*)(int), boost::_bi::list0&gt; (this=0xf2e3610, f=@0xf2e3608, </p> <blockquote> <p> a=@0x425560cf) at /home/vnmr1/phil/boost_1_46_1/boost/bind/bind.hpp:253 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9" title="#9: Bugs: config_info ambiguity error (closed: Invalid)">#9</a> 0x00000000004083f8 in boost::_bi::bind_t&lt;void, void (*)(int), boost::_bi::list1&lt;boost::_bi::value&lt;int&gt; &gt; &gt;::operator() (this=0xf2e3608) </p> <blockquote> <p> at /home/vnmr1/phil/boost_1_46_1/boost/bind/bind_template.hpp:20 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/10" title="#10: Bugs: allyourbase.jam file is bad. (closed: Out of Date)">#10</a> 0x0000000000408416 in boost::detail::thread_data&lt;boost::_bi::bind_t&lt;void, void (*)(int), boost::_bi::list1&lt;boost::_bi::value&lt;int&gt; &gt; &gt; &gt;::run ( </p> <blockquote> <p> this=0xf2e3480) at /home/vnmr1/phil/boost_1_46_1/boost/thread/detail/thread.hpp:61 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/11" title="#11: Bugs: why not using mt19937? (closed: Fixed)">#11</a> 0x00002b1169e3d914 in thread_proxy () </p> <blockquote> <p> from /home/vnmr1/phil/lib/libboost_thread.so.1.46.1 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/12" title="#12: Bugs: Can't specify VertexPredicate (closed: Fixed)">#12</a> 0x0000003906a06367 in start_thread () from /lib64/libpthread.so.0 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/13" title="#13: Bugs: iterator_adapter and abstract classes (closed: Out of Date)">#13</a> 0x0000003905ed30ad in clone () from /lib64/libc.so.6 </p> <p> Thanks, -Phil </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 12 May 2011 17:34:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5523#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5523#comment:2</guid> <description> <p> I think the crash in Pool is the sympton not the cause - if I remove all the thread code, and just call worker() directly in your test program, then I still get a crash, and Pool isn't mentioned at all: </p> <pre class="wiki">Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb74d1940 (LWP 6630)] 0x0804fa86 in boost::numeric::in&lt;long, boost::numeric::interval_lib::policies&lt;boost::numeric::interval_lib::rounded_math&lt;long&gt;, boost::numeric::interval_lib::checking_strict&lt;long&gt; &gt; &gt; (x=@0xbfd81920, y=@0xb7452700) at /home/john/boost/Trunk/boost/numeric/interval/utility.hpp:121 121 return y.lower() &lt;= x &amp;&amp; x &lt;= y.upper(); (gdb) bt #0 0x0804fa86 in boost::numeric::in&lt;long, boost::numeric::interval_lib::policies&lt;boost::numeric::interval_lib::rounded_math&lt;long&gt;, boost::numeric::interval_lib::checking_strict&lt;long&gt; &gt; &gt; (x=@0xbfd81920, y=@0xb7452700) at /home/john/boost/Trunk/boost/numeric/interval/utility.hpp:121 #1 0x0804e29d in boost::detail::sh::pool::deallocate (p=0x806605c, s=52) at ../../../boost/detail/block_base.hpp:172 #2 0x08051c57 in boost::detail::sh::block&lt;std::pair&lt;int, int&gt; &gt;::operator delete (p=0x806605c) at ../../../boost/detail/block_base.hpp:309 #3 0x08054b4c in ~block (this=0x806605c) at ../../../boost/detail/block_base.hpp:258 #4 0x0804d286 in boost::detail::sp_counted_base::destroy (this=0x806605c) at /home/john/boost/Trunk/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:126 #5 0x0804d348 in boost::detail::sp_counted_base::weak_release (this=0x806605c) at /home/john/boost/Trunk/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:159 #6 0x0804d2fd in boost::detail::sp_counted_base::release (this=0x806605c) at /home/john/boost/Trunk/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:146 #7 0x0805320a in boost::detail::sh::block_ptr_common&lt;std::pair&lt;int, int&gt; &gt;::reset (this=0x8064bc4, p=0x0) at ../../../boost/detail/block_ptr_base.hpp:124 #8 0x08051d9b in boost::detail::sh::block_ptr&lt;std::pair&lt;int, int&gt; &gt;::release ( this=0x8064bc4, d=true) at ../../../boost/block_ptr.hpp:445 ---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit--- #9 0x080500cf in ~block_ptr (this=0x8064bc4) at ../../../boost/block_ptr.hpp:405 #10 0xb7500084 in exit () from /lib/tls/i686/cmov/libc.so.6 #11 0xb74e8458 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6 #12 0x0804c531 in _start () </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 09 Jun 2011 03:49:36 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5523#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5523#comment:3</guid> <description> <p> I also encountered the same problem. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 09 Jun 2011 03:53:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5523#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5523#comment:4</guid> <description> <p> I also encountered the same problem. </p> <p> segment falut. </p> <p> <a class="missing ticket">#0</a> 0x0000000000479141 in boost::simple_segregated_storage&lt;unsigned long&gt;::malloc (this=0x6f5048) at /usr/include/boost/pool/simple_segregated_storage.hpp:104 104 first = nextof(first); (gdb) bt <a class="missing ticket">#0</a> 0x0000000000479141 in boost::simple_segregated_storage&lt;unsigned long&gt;::malloc (this=0x6f5048) at /usr/include/boost/pool/simple_segregated_storage.hpp:104 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> 0x0000000000479edf in boost::pool&lt;boost::default_user_allocator_new_delete&gt;::malloc (this=0x6f5048) at /usr/include/boost/pool/pool.hpp:221 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a> 0x0000000000479f24 in boost::singleton_pool&lt;obt::ipmsg, 1056u, boost::default_user_allocator_new_delete, boost::details::pool::pthread_mutex, 32u&gt;::malloc () </p> <blockquote> <p> at /usr/include/boost/pool/singleton_pool.hpp:59 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3" title="#3: Bugs: automatic conversion and overload proble (closed: fixed)">#3</a> 0x00000000004acbec in obt::send_handler_impl::send_task_msg (this=0x1edfad40, tsk=0x22942ad8, buf=0x2aaafbcca24e "o\002\003?@hKi!", len=964) </p> <blockquote> <p> at /home/OpenIPTV/trunk/p2pcore/server/dataserver/main/sender.cpp:103 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4" title="#4: Bugs: any_ptr in any library documentation? (closed: Fixed)">#4</a> 0x00000000004acfb5 in obt::send_handler_impl::svc (this=0x1edfad40) at /home/OpenIPTV/trunk/p2pcore/server/dataserver/main/sender.cpp:183 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5" title="#5: Bugs: shared_ptr and self-owning objects (closed: Fixed)">#5</a> 0x00000000004adfc4 in boost::_mfi::mf0&lt;int, obt::send_handler_impl&gt;::operator() (this=0x1edfa8a0, p=0x1edfad40) at /usr/include/boost/bind/mem_fn_template.hpp:45 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6" title="#6: Bugs: tie in utility.hpp and tuple.hpp clash. (closed: Duplicate)">#6</a> 0x00000000004ae032 in boost::_bi::list1&lt;boost::_bi::value&lt;obt::send_handler_impl*&gt; &gt;::operator()&lt;int, boost::_mfi::mf0&lt;int, obt::send_handler_impl&gt;, boost::_bi::list0&gt; ( </p> <blockquote> <p> this=0x1edfa8b0, f=@0x1edfa8a0, a=@0x429eb04f) at /usr/include/boost/bind.hpp:220 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7" title="#7: Bugs: g++ 2.96 requires NO_STRINGSTREAM (closed: Fixed)">#7</a> 0x00000000004ae070 in boost::_bi::bind_t&lt;int, boost::_mfi::mf0&lt;int, obt::send_handler_impl&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;obt::send_handler_impl*&gt; &gt; &gt;::operator() ( </p> <blockquote> <p> this=0x1edfa8a0) at /usr/include/boost/bind/bind_template.hpp:20 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8" title="#8: Bugs: prop in undirected graph + out_edges (closed: Works For Me)">#8</a> 0x00000000004ae08f in boost::detail::function::function_obj_invoker0&lt;boost::_bi::bind_t&lt;int, boost::_mfi::mf0&lt;int, obt::send_handler_impl&gt;, boost::_bi::list1&lt;boost::_bi::value&lt;obt::send_handler_impl*&gt; &gt; &gt;, int&gt;::invoke (function_obj_ptr={obj_ptr = 0x1edfa8a0, const_obj_ptr = 0x1edfa8a0, func_ptr = 0x1edfa8a0, data = "?"}) </p> <blockquote> <p> at /usr/include/boost/function/function_template.hpp:119 </p> </blockquote> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9" title="#9: Bugs: config_info ambiguity error (closed: Invalid)">#9</a> 0x000000000047ff6c in boost::function0&lt;int, std::allocator&lt;void&gt; &gt;::operator() (this=0x1edfade8) at /usr/include/boost/function/function_template.hpp:576 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/10" title="#10: Bugs: allyourbase.jam file is bad. (closed: Out of Date)">#10</a> 0x000000000047ff95 in obt::thread::svc (arg=0x1edfadd8) at /home/OpenIPTV/trunk/p2pcore/server/dataserver/../../include/obt/thread.h:23 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/11" title="#11: Bugs: why not using mt19937? (closed: Fixed)">#11</a> 0x000000363ec064a7 in start_thread () from /lib64/libpthread.so.0 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/12" title="#12: Bugs: Can't specify VertexPredicate (closed: Fixed)">#12</a> 0x000000363e0d3c2d in clone () from /lib64/libc.so.6 (gdb) quit </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 10 Jun 2011 02:11:07 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5523#comment:5 https://svn.boost.org/trac10/ticket/5523#comment:5 <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">invalid</span> </li> </ul> Ticket