title: multithread std::shared_ptr read / write
body: <p>I have a double free bug using std::shared_ptr and trying to get know why. I am using shared_ptr in multithread environment , one thread sometimes replaces some element in a global array </p>
  
  <pre><code>std::shared_ptr&lt;Bucket&gt;  globalTable[100]; // global elements storage
  </code></pre>
  
  <p>using:</p>
  
  <pre><code>globalTable[idx].reset(newBucket);
  </code></pre>
  
  <p>and the other thread reads this table sometimes using :</p>
  
  <pre><code>std::shared_ptr&lt;Bucket&gt; bkt(globalTable[pIdx]);
  // do calculations with bkt-&gt; items
  </code></pre>
  
  <p>After this I am receiving double-free error, and AddressSanitizer says that the second code tries to free an object that was destroyed by the first one . How it is possible ? As I know shared_ptr must be completly thread safe. </p>