title: std::thread problems
body: <p>I think I have a kind really bad concepts problems. Why I simple get a lot of race conditions error with valgrind.
  First i thought that could be a bug, and I saw in forums that an updated rolling release of linux will solve this... so now i have opensuse tubleweed, 100% updated.
  The following code muss have something very wrong:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;thread&gt;
  
  using namespace std;
  
  class FOO
  {
  public:
      void do_something ()
      {
          cout&lt;&lt;"cout somethin\n";
      }
  };
  
  int main ()
  {
      FOO foo;
      std::thread t (&amp;FOO::do_something,&amp;foo);
      t.join();
  }
  </code></pre>
  
  <p>When i do a</p>
  
  <pre><code>valgrind --tool=drd ./oncordia
  </code></pre>
  
  <p>i have to try 5 times or more and i get the following errors:</p>
  
  <pre><code>==6218== drd, a thread error detector
  ==6218== Copyright (C) 2006-2010, and GNU GPL'd, by Bart Van Assche.
  ==6218== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
  ==6218== Command: ./oncordia
  ==6218== 
  cout somethin
  ==6218== Conflicting store by thread 1 at 0x05b5d050 size 8
  ==6218==    at 0x418E62: std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;::~_Impl() (in /home/ezequiel/projects/oncordia/build/oncordia)
  ==6218==    by 0x419099: std::_Sp_destroy_inplace&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;::operator()(std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;*) const (in /home/ezequiel/projects/oncordia/build/oncordia)
  ==6218==    by 0x418EDC: std::_Sp_counted_deleter&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;*, std::_Sp_destroy_inplace&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, (__gnu_cxx::_Lock_policy)2&gt;::_M_dispose() (shared_ptr_base.h:351)
  ==6218==    by 0x4180B7: std::_Sp_counted_base&lt;(__gnu_cxx::_Lock_policy)2&gt;::_M_release() (shared_ptr_base.h:146)
  ==6218==    by 0x417F62: std::__shared_count&lt;(__gnu_cxx::_Lock_policy)2&gt;::~__shared_count() (shared_ptr_base.h:551)
  ==6218==    by 0x417E99: std::__shared_ptr&lt;std::thread::_Impl_base, (__gnu_cxx::_Lock_policy)2&gt;::~__shared_ptr() (shared_ptr_base.h:751)
  ==6218==    by 0x417EB3: std::shared_ptr&lt;std::thread::_Impl_base&gt;::~shared_ptr() (shared_ptr.h:93)
  ==6218==    by 0x418037: std::thread::thread&lt;void (FOO::*)(), FOO*&gt;(void (FOO::*&amp;&amp;)(), FOO*&amp;&amp;) (thread:135)
  ==6218==    by 0x417CCB: main (main.cpp:18)
  ==6218== Address 0x5b5d050 is at offset 32 from 0x5b5d030. Allocation context:
  ==6218==    at 0x4C2AAB7: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_drd-amd64-linux.so)
  ==6218==    by 0x418A5F: __gnu_cxx::new_allocator&lt;std::_Sp_counted_ptr_inplace&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, (__gnu_cxx::_Lock_policy)2&gt; &gt;::allocate(unsigned long, void const*) (new_allocator.h:92)
  ==6218==    by 0x418846: std::__shared_count&lt;(__gnu_cxx::_Lock_policy)2&gt;::__shared_count&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Sp_make_shared_tag, std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;*, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; const&amp;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr_base.h:517)
  ==6218==    by 0x418775: std::__shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, (__gnu_cxx::_Lock_policy)2&gt;::__shared_ptr&lt;std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Sp_make_shared_tag, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; const&amp;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr_base.h:986)
  ==6218==    by 0x4186C1: std::shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;::shared_ptr&lt;std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Sp_make_shared_tag, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; const&amp;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr.h:313)
  ==6218==    by 0x4185A3: std::shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; std::allocate_shared&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; const&amp;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr.h:531)
  ==6218==    by 0x418360: std::shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; std::make_shared&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr.h:547)
  ==6218==    by 0x4181BF: std::shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; std::thread::_M_make_routine&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (thread:194)
  ==6218==    by 0x418005: std::thread::thread&lt;void (FOO::*)(), FOO*&gt;(void (FOO::*&amp;&amp;)(), FOO*&amp;&amp;) (thread:135)
  ==6218==    by 0x417CCB: main (main.cpp:18)
  ==6218== Other segment start (thread 2)
  ==6218==    (thread finished, call stack no longer available)
  ==6218== Other segment end (thread 2)
  ==6218==    (thread finished, call stack no longer available)
  ==6218== 
  ==6218== Conflicting store by thread 1 at 0x05b5d050 size 8
  ==6218==    at 0x417EC6: std::thread::_Impl_base::~_Impl_base() (in /home/ezequiel/projects/oncordia/build/oncordia)
  ==6218==    by 0x418E74: std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;::~_Impl() (in /home/ezequiel/projects/oncordia/build/oncordia)
  ==6218==    by 0x419099: std::_Sp_destroy_inplace&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;::operator()(std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;*) const (in /home/ezequiel/projects/oncordia/build/oncordia)
  ==6218==    by 0x418EDC: std::_Sp_counted_deleter&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;*, std::_Sp_destroy_inplace&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, (__gnu_cxx::_Lock_policy)2&gt;::_M_dispose() (shared_ptr_base.h:351)
  ==6218==    by 0x4180B7: std::_Sp_counted_base&lt;(__gnu_cxx::_Lock_policy)2&gt;::_M_release() (shared_ptr_base.h:146)
  ==6218==    by 0x417F62: std::__shared_count&lt;(__gnu_cxx::_Lock_policy)2&gt;::~__shared_count() (shared_ptr_base.h:551)
  ==6218==    by 0x417E99: std::__shared_ptr&lt;std::thread::_Impl_base, (__gnu_cxx::_Lock_policy)2&gt;::~__shared_ptr() (shared_ptr_base.h:751)
  ==6218==    by 0x417EB3: std::shared_ptr&lt;std::thread::_Impl_base&gt;::~shared_ptr() (shared_ptr.h:93)
  ==6218==    by 0x418037: std::thread::thread&lt;void (FOO::*)(), FOO*&gt;(void (FOO::*&amp;&amp;)(), FOO*&amp;&amp;) (thread:135)
  ==6218==    by 0x417CCB: main (main.cpp:18)
  ==6218== Address 0x5b5d050 is at offset 32 from 0x5b5d030. Allocation context:
  ==6218==    at 0x4C2AAB7: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_drd-amd64-linux.so)
  ==6218==    by 0x418A5F: __gnu_cxx::new_allocator&lt;std::_Sp_counted_ptr_inplace&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, (__gnu_cxx::_Lock_policy)2&gt; &gt;::allocate(unsigned long, void const*) (new_allocator.h:92)
  ==6218==    by 0x418846: std::__shared_count&lt;(__gnu_cxx::_Lock_policy)2&gt;::__shared_count&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Sp_make_shared_tag, std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;*, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; const&amp;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr_base.h:517)
  ==6218==    by 0x418775: std::__shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, (__gnu_cxx::_Lock_policy)2&gt;::__shared_ptr&lt;std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Sp_make_shared_tag, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; const&amp;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr_base.h:986)
  ==6218==    by 0x4186C1: std::shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;::shared_ptr&lt;std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Sp_make_shared_tag, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; const&amp;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr.h:313)
  ==6218==    by 0x4185A3: std::shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; std::allocate_shared&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; const&amp;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr.h:531)
  ==6218==    by 0x418360: std::shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; std::make_shared&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr.h:547)
  ==6218==    by 0x4181BF: std::shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; std::thread::_M_make_routine&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (thread:194)
  ==6218==    by 0x418005: std::thread::thread&lt;void (FOO::*)(), FOO*&gt;(void (FOO::*&amp;&amp;)(), FOO*&amp;&amp;) (thread:135)
  ==6218==    by 0x417CCB: main (main.cpp:18)
  ==6218== Other segment start (thread 2)
  ==6218==    (thread finished, call stack no longer available)
  ==6218== Other segment end (thread 2)
  ==6218==    (thread finished, call stack no longer available)
  ==6218== 
  ==6218== Conflicting load by thread 1 at 0x05b5d060 size 8
  ==6218==    at 0x417F4C: std::__shared_count&lt;(__gnu_cxx::_Lock_policy)2&gt;::~__shared_count() (shared_ptr_base.h:550)
  ==6218==    by 0x417E99: std::__shared_ptr&lt;std::thread::_Impl_base, (__gnu_cxx::_Lock_policy)2&gt;::~__shared_ptr() (shared_ptr_base.h:751)
  ==6218==    by 0x417EB3: std::shared_ptr&lt;std::thread::_Impl_base&gt;::~shared_ptr() (shared_ptr.h:93)
  ==6218==    by 0x417EDC: std::thread::_Impl_base::~_Impl_base() (in /home/ezequiel/projects/oncordia/build/oncordia)
  ==6218==    by 0x418E74: std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;::~_Impl() (in /home/ezequiel/projects/oncordia/build/oncordia)
  ==6218==    by 0x419099: std::_Sp_destroy_inplace&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;::operator()(std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;*) const (in /home/ezequiel/projects/oncordia/build/oncordia)
  ==6218==    by 0x418EDC: std::_Sp_counted_deleter&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;*, std::_Sp_destroy_inplace&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, (__gnu_cxx::_Lock_policy)2&gt;::_M_dispose() (shared_ptr_base.h:351)
  ==6218==    by 0x4180B7: std::_Sp_counted_base&lt;(__gnu_cxx::_Lock_policy)2&gt;::_M_release() (shared_ptr_base.h:146)
  ==6218==    by 0x417F62: std::__shared_count&lt;(__gnu_cxx::_Lock_policy)2&gt;::~__shared_count() (shared_ptr_base.h:551)
  ==6218==    by 0x417E99: std::__shared_ptr&lt;std::thread::_Impl_base, (__gnu_cxx::_Lock_policy)2&gt;::~__shared_ptr() (shared_ptr_base.h:751)
  ==6218==    by 0x417EB3: std::shared_ptr&lt;std::thread::_Impl_base&gt;::~shared_ptr() (shared_ptr.h:93)
  ==6218==    by 0x418037: std::thread::thread&lt;void (FOO::*)(), FOO*&gt;(void (FOO::*&amp;&amp;)(), FOO*&amp;&amp;) (thread:135)
  ==6218== Address 0x5b5d060 is at offset 48 from 0x5b5d030. Allocation context:
  ==6218==    at 0x4C2AAB7: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_drd-amd64-linux.so)
  ==6218==    by 0x418A5F: __gnu_cxx::new_allocator&lt;std::_Sp_counted_ptr_inplace&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, (__gnu_cxx::_Lock_policy)2&gt; &gt;::allocate(unsigned long, void const*) (new_allocator.h:92)
  ==6218==    by 0x418846: std::__shared_count&lt;(__gnu_cxx::_Lock_policy)2&gt;::__shared_count&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Sp_make_shared_tag, std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;*, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; const&amp;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr_base.h:517)
  ==6218==    by 0x418775: std::__shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, (__gnu_cxx::_Lock_policy)2&gt;::__shared_ptr&lt;std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Sp_make_shared_tag, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; const&amp;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr_base.h:986)
  ==6218==    by 0x4186C1: std::shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;::shared_ptr&lt;std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Sp_make_shared_tag, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; const&amp;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr.h:313)
  ==6218==    by 0x4185A3: std::shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; std::allocate_shared&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::allocator&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; const&amp;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr.h:531)
  ==6218==    by 0x418360: std::shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; std::make_shared&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;, std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (shared_ptr.h:547)
  ==6218==    by 0x4181BF: std::shared_ptr&lt;std::thread::_Impl&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt; &gt; std::thread::_M_make_routine&lt;std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt; &gt;(std::_Bind_result&lt;void, std::_Mem_fn&lt;void (FOO::*)()&gt; ()(FOO*)&gt;&amp;&amp;) (thread:194)
  ==6218==    by 0x418005: std::thread::thread&lt;void (FOO::*)(), FOO*&gt;(void (FOO::*&amp;&amp;)(), FOO*&amp;&amp;) (thread:135)
  ==6218==    by 0x417CCB: main (main.cpp:18)
  ==6218== Other segment start (thread 2)
  ==6218==    (thread finished, call stack no longer available)
  ==6218== Other segment end (thread 2)
  ==6218==    (thread finished, call stack no longer available)
  ==6218== 
  ==6218== 
  ==6218== For counts of detected and suppressed errors, rerun with: -v
  </code></pre>
  
  <p>thanks!!</p>