title: C++11 std::thread join crashes with system_error exception and SIGABRT on Xcode 6?
body: <p>Here is a simple thread trace program. The thread simply prints the first ten integers and then the "thread is done" message.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;numeric&gt;
  #include &lt;thread&gt;
  
  void f();
  
  int main(int argc, const char * argv[]) {
      std::thread t(f);
  
      std::cout &lt;&lt; "Thread start" &lt;&lt; std::endl;
  
      t.detach();
      t.join();
  
      std::cout &lt;&lt; "Thread end" &lt;&lt; std::endl;
  
      return 0;
  }
  
  void f()
  {
      std::vector&lt;int&gt; a(10);
      std::iota(a.begin(), a.end(), 0);
  
      for(const int&amp; i : a)
      {
          std::cout &lt;&lt; i &lt;&lt; std:: endl;
      }
      std::cout &lt;&lt; "Thread is done." &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>However, when it runs, t.join throws a std::__1::system_error exception, somewhere in the libc ABI, leading the program to terminate with SIGABRT:</p>
  
  <pre><code>Thread start
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
  Thread is done.
  libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: thread::join failed: No such process
  </code></pre>
  
  <p>Sometimes when it runs the exception in the main thread occurs (at the same place) before thread t runs (but it still does):</p>
  
  <pre><code>Thread start
  libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: thread::join failed: No such process
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
  Thread is done.
  </code></pre>