title: Segmentation fault when trying to pass dynamic array to processes
body: <p>I tried to pass dynamic array from 0 process to 1 and vice versa. Getting segmentation fault in process 1. All matrices printed as expected. What could be the problem in this situation?</p>
  <pre><code>int main(int argc, char **argv){
    MPI_Init(&amp;argc,&amp;argv);
    int n;
    cin &gt;&gt; n; 
    int *matrix = new int[n*n];
    int *matrix2 = new int[n*n];
    int i,j,ProcNum,ProcRank;
    MPI_Comm_size(MPI_COMM_WORLD, &amp;ProcNum);
    MPI_Comm_rank(MPI_COMM_WORLD, &amp;ProcRank);
    MPI_Status status;
    if (ProcRank == 0){
      /* Filling matrices here with i*n + j values*/
      MPI_Send(&amp;n, 1, MPI_INT, 1, 1, MPI_COMM_WORLD);
      MPI_Send(&amp;(matrix[0]), n*n, MPI_INT, 1, 2, MPI_COMM_WORLD);
      MPI_Recv(&amp;(matrix[0]), n*n, MPI_INT, 1, 2, MPI_COMM_WORLD, &amp;status);
      print_matrix(matrix,n);
    }
    if (ProcRank &gt; 0) {
      MPI_Recv(&amp;n, 1, MPI_INT, 0, 1, MPI_COMM_WORLD, &amp;status);
      MPI_Recv(&amp;(matrix[0]), n*n, MPI_INT, 0, 2, MPI_COMM_WORLD, &amp;status);
      /*passing i-j values to matrix and printing them here*/
      MPI_Send(&amp;(matrix[0]), n*n, MPI_INT, 0, 2, MPI_COMM_WORLD);
    }
    MPI_Finalize();
    delete matrix;
    delete matrix2;
    return EXIT_SUCCESS;
  }
  </code></pre>