title: Segmentation Fault when deleting an existing object
body: <p>My code have one thread continuosly handling objects queued by other threads. Queued objects are created using "new" in a function that will have finished when the object will be handled. I have no problem with this but deleting the object.
  Should I just not delete the object? Maybe change the way of passing/creating this objects?</p>
  
  <pre><code>Object* myQueue[10];
  
  function() {
      Object* myobject = new Object();
      queueObject(myobject);
  }
  
  queueObject(Object* object) {
      myQueue[index_x] = object;
      sem_post(&amp;mySemaphore);
  }
  
  
  //// Thread 1
  function();
  ...
  
  //// Thread 2
  handleObjects() {
      while(true) {
          sem_wait(&amp;mySemaphore);
          // handle myQueue[index_x]
          delete myQueue[index_x]; ---&gt; this produces Segmentation Fault
      }
  }
  </code></pre>
  
  <p>(the treatment of index_x is not posted to abbreviate)</p>