title: Segmentation fault after using MPI_Finalize()
body: <p>I am programming in c using openMPI.  My code is posted below.  What happens is that I receive a segmentation fault error whenever I run this program.  I believe that I have isolated the problem by using these printf statements.  The segmentation seems to happen after the MPI_Finalize().  Any help is greatly appreciated.</p>
  
  <p>The error I receive is:</p>
  
  <pre><code>[linuxscc003:10019] *** Process received signal ***
  [linuxscc003:10019] Signal: Segmentation fault (11)
  [linuxscc003:10019] Signal code: Address not mapped (1)
  </code></pre>
  
  <p>and my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;mpi.h&gt; 
  
  int main(int argc, char** argv) 
  {
      int i = 0; //index
      int comm_sz, my_rank;
      int part_sum = 0;
      //size of the array is hard-coded in, 
  
      MPI_Init(NULL,NULL);
      MPI_Comm_size(MPI_COMM_WORLD, &amp;comm_sz);
      MPI_Comm_rank(MPI_COMM_WORLD, &amp;my_rank);
  
      if(my_rank == 0)
      {
          int* array;
          //generate the array of n elements
          printf("There are %d array elements\n", comm_sz);
          array = (int*)malloc(sizeof(int*)*comm_sz);
          for(i = 0; i &lt; comm_sz; i++)
          {
              //we don't want to count zero in here
              //nobody likes zero
              array[i] = (i+1); 
          }
          for(i = 1; i &lt; comm_sz; i++)
          {
              MPI_Send(&amp;array[i], sizeof(int*), MPI_INT, i, 0, MPI_COMM_WORLD);
          }   
          //part_sum = 1;
          free(array);
          printf("freed array!\n");
      }
  
      if(my_rank != 0)
      {
          MPI_Recv(&amp;part_sum, sizeof(int*), MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
          printf("proc %d out of %d, I have received %d!\n", my_rank, comm_sz, part_sum);
  
      }
  
  
  
      printf("proc %d signing off!\n",my_rank);
      MPI_Finalize();
      printf("proc %d signed off!\n",my_rank);
      return 0;
  } 
  </code></pre>