title: Segmentation fault after the call of pthread_join()
body: <p>I have written the following code using the POSIX pthread library: </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;pthread.h&gt;
  
  pthread_t pid1,pid2;
  
  void *test(void *arg)
  {
  void **end;
  printf("\nNew Thread ID: 0x%x\n",(unsigned int)pid2);
  pthread_join(pid1,end);
  printf("\nNew Thread going to go off\n");
  printf("\nNew Thread ID: 0x%x\n",(unsigned int)pid2);
  return ((void *)NULL);
  }    
  
  int main()
  {
  pid1 = pthread_self();
  pthread_create(&amp;pid2,NULL,test,NULL);
  printf("\nMain Thread ID: 0x%x\n",(unsigned int)pid1);
  sleep(2);
  printf("\nI am going off\n");
  pthread_exit(0);
  }
  </code></pre>
  
  <p>On executing the code I got the following output:</p>
  
  <pre>
  Main Thread ID: 0xb7880b30
  New Thread ID: 0xb787eb70
  I am going off
  Segmentation fault
  </pre>
  
  <p>As I studied, the thread(pid2) calling the pthread_join will block until the thread passed in argument(pid1) calls pthread_exit(). And pthread_exit() is used to stop the execution of a particular thread letting all others to keep on executing. </p>
  
  <p>I want to know why I got Segmentation Fault at last. </p>
  
  <p>Please explain me properly.</p>