title: Programm terminating "std::bad_alloc" after some time
body: <p>I wrapped my mind around this, yet can not find the error. Could anyone help me where I did bad programming. <br>
  One <code>boost::thread</code> receives <code>strings</code> over a socket, splits them to <code>vector&lt;string&gt;</code> and sorts them into the right variable inside <code>shared class</code>. Other threads read from there. I tried to make it thread safe via mutex as shown <a href="https://stackoverflow.com/questions/989795/example-for-boost-shared-mutex-multiple-reads-one-write">here</a>. <br>I appreciate any help, even small hints :)<br>
  This is how the program terminates:</p>
  
  <pre><code>Looping...&lt;enter to exit&gt;
  terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
  Aborted (core dumped)
  </code></pre>
  
  <p>And this is the corresponding file. It is entangled with <a href="http://www.ros.org/" rel="nofollow noreferrer">ROS</a>, but that part shouldn't be the verdict.</p>
  
  <pre><code>class shared
  {
  public:
      shared() : count(0) {/*emp. body*/ } //constructor
  
      void setvec(vector&lt;string&gt; &amp;strVec, int type){
  
          boost::upgrade_lock&lt;boost::shared_mutex&gt; lock(mtx);
          boost::upgrade_to_unique_lock&lt;boost::shared_mutex&gt; uniqueLock(lock);
  
          switch(type) {
          case 1: typ1acc = strVec; setsensor[0] = true; break;
          case 2: typ2mag = strVec; setsensor[1] = true; break;
          case 3: typ3 = strVec; setsensor[2] = true; break;
          }/**/
      }
      vector&lt;string&gt; getvec(int type) {
          boost::shared_lock&lt;boost::shared_mutex&gt; lock(mtx);
          switch(type) {
          case 1: tmp = typ1acc; break;
          case 2: tmp = typ2mag; break;
          case 3: tmp = typ3; break;
          }
          return tmp;
      }
  private:
      boost::shared_mutex mtx;
      vector&lt;string&gt; tmp;
      vector&lt;string&gt; typ1acc;
      vector&lt;string&gt; typ2mag;
      vector&lt;string&gt; typ3;
  };
  
  shared c; //class object
  </code></pre>
  
  <p>Class is called from multiple boost::threads:<br></p>
  
  <pre><code>    //socket function which sorts vectors into shared class
      //this happens from one boost::thread 
      int type; //key sort by sensor type 
      vector&lt;string&gt; strVec;
      c.setvec(strVec,type);
  
      //multiple boost::threads call this to read the vectors
      //this happens from multiple boost::thread 
          strVec = c.getvec(type);
  </code></pre>