title: Cannot figure out double free or corruption (fasttop) error
body: <p>The following method generates a double free or corruption (fasttop) error (on the first line) during run time. It happens randomly i.e. it might happen at the first second or the 35 second while the program is running.</p>
  
  <pre><code>QSharedPointer&lt;QPixmap&gt; Utils::loadImg(QString fileName)
  {
      QPixmap *pixmap = new QPixmap(fileName);
      QSharedPointer&lt;QPixmap&gt; qspPixmap(pixmap);
      return qspPixmap;
  }
  </code></pre>
  
  <p>This is a static method that I am calling to get the pointer (actually using smart pointers that Qt provides) of an pixmap. Once I get the smart pointer I store it to a map structure for later use. When I remove the entry from the map structure it should free the memory and it seems like that it does so.
  Note that the loadImg(QString) method is called by another method that is running on its own thread (using QtConcurrent and QFuture provided by Qt).</p>
  
  <p>I really cannot figure out what the problem is. The debugger shows the first line as the problematic one.</p>
  
  <p>Thank for your help in advance.</p>