title: double free or corruption with shared pointers
body: <p>So the essence of my problem is this:</p>
  
  <pre><code>//Big.h
  class Big{
      public:
          int a, b;
  };
  
  //Mini.h
  class Big;
  class Mini{
      public:
          Mini(float a, shared_ptr&lt;Big&gt; ptb):ma(a), me(-a), ptb(ptb){};
          float ma, me;
          shared_ptr&lt;Big&gt; ptb;
  };
  
  //main
  int main(){
      std::list&lt;Mini&gt; lm;
      if(true){ //Or some sub function or rutin
          Big big; big.a = 100; big.b = 200;
          Mini derp(5, shared_ptr&lt;Big&gt;(&amp;big));
          lm.push_front(derp);
      }
    //Do something
  };
  </code></pre>
  
  <p>Compiles fine but it gives a "<em>double free or corruption</em>" when exiting main (in the full program this is just a sub function)</p>
  
  <p>I suspect the <a href="http://www.cplusplus.com/reference/memory/shared_ptr/" rel="noreferrer"><code>shared_ptr</code></a> to <code>big</code> is being freed at some point and then again when exiting main, but I'm not sure and have no idea of how to fix it. Can someone please explain to me the reason of this error?</p>
  
  <p>I red that I had to <code>NULL</code> the pointer to but I don't know where.
  Or maybe I'm just using the wrong smart pointer or something like that?</p>
  
  <p>Thanks</p>