title: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::thread_resource_error> >
body: <p>I need some help with this exception, I am implementing a NPAPI plugin to be able to use local sockets from browser extensions, to do that I am using Firebreath framework.</p>
  
  <p>For socket and connectivity I am using Boost asio with async calls and a thread pool of 5 worker threads.
  Also I have a deadline per thread to implement a transmission timeout.</p>
  
  <p>My extension workflow with the plugin is as this:</p>
  
  <ol>
  <li>Open socket 1(this starts a async_receive and the deadline
  async_wait) </li>
  <li>Write in the socket 1</li>
  <li><p>Get response 1</p></li>
  <li><p>Open another socket 2</p></li>
  <li><p>Write in the socket 2</p></li>
  <li><p>Write socket 1</p></li>
  <li><p>Close socket 1
  (socket.cancel(), deadline.cancel(), socket.shutdown(), socket
  release). </p></li>
  <li><p>Get response 2</p></li>
  <li>Write socket 2</li>
  <li>Close socket 2</li>
  </ol>
  
  <p>As everything is cross language and async is really hard to debug but all open, write or close are called from javascript and the read from socket 1 that calls open 2, write 2,  write 1 and close 1 in that order.</p>
  
  <p>Maybe evrything I am telling is unrelated as the call stack when the exception is thrown does not show any of my functions and only show that it is inside a <code>malloc</code> that calls <code>_heap_alloc_dbg_impl</code></p>
  
  <p>As it is it usually fails in the 2nd or 3rd full cycle and it seems that happens between steps 5 and 7.</p>
  
  <p>But, I think that it must be asio related as doing everything with a single worker thread just crashes with the exception on the first cycle.</p>
  
  <p>I am open to publish more information code if you need it.</p>
  
  <p><strong>Update 1:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/KWMTV.png" alt="VS when breaking"></p>
  
  <p><strong>Update 2:</strong></p>
  
  <p>There are 10 threads are launched with:</p>
  
  <pre><code>workPtr.reset( new boost::asio::io_service::work(io_service));
  
  for ( int i = 0; i &lt; 10; ++i) {
      m_threadGroup.create_thread( boost::bind(&amp;boost::asio::io_service::run, &amp;io_service) );
  }
  </code></pre>
  
  <p>The 11th _threadstartex I don't know who launched it</p>
  
  <p>On another thread (not the one that VS claims as causing the crash) there is a <code>join_all()</code> in process because my class is being destroyed but I think it shouldn't, so maybe this crash is due to another exception and the Firebreath process to close everything when it crashes.</p>