title: Segfault immediately after pthread creation
body: <p>I have a producer/consumer concurrency problem that I'm working on.  The problem is that I'm getting a segfault thrown immediately after trying to create my first thread. </p>
  
  <p>Relevant code:</p>
  
  <p>customer is a struct declared as:</p>
  
  <pre><code>struct pr2_customer
  {
      pthread_t customer_id;
  };
  typedef struct pr2_customer customer;
  </code></pre>
  
  <p>customers is a c++ vector, declared like:</p>
  
  <pre><code>vector&lt;customer&gt; customers;
  </code></pre>
  
  <p>Create the thread:</p>
  
  <pre><code>for(int i = 0; i &lt; ncustomers; i++)
  {
      cout&lt;&lt;"creating a customer\n";
      pthread_create(&amp;customers[i].customer_id, &amp;attr, customerAction, (void*)i);
  }
  </code></pre>
  
  <p>Output:</p>
  
  <p>creating a customer<br>
  segfault</p>
  
  <p>customerAction has a cout statement as it's first line which never gets executed, leading me to believe the thread is never created.</p>
  
  <p>Any help is greatly appreciated.</p>