title: program ended prematurely and may have crashed. exit code 0xc0000005
body: <p>Here is my code I want to multiply a 2D array with a vector array:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;mpi.h&gt;
  using namespace std;
  int v_array[10] ;
  int ch_size, start, close;
  int res ;
  int rows, cols;
  
  int main(int argc, char *argv[])
  {
      int pro_id, tot_pros;
      MPI_Init(&amp;argc, &amp;argv); 
      MPI_Comm_rank(MPI_COMM_WORLD, &amp;pro_id); 
      MPI_Comm_size(MPI_COMM_WORLD, &amp;tot_pros); 
  
      if (pro_id == 0) {
          cout &lt;&lt; "Enter rows and columns: ";
          cin &gt;&gt; rows &gt;&gt; cols;
  
          int **array = new int*[rows];
          int size1 = rows * cols;
          array[0] = new int[size1];
          for (int j = 1; j &lt; rows; j++) {
              array[j] = &amp;array[0][j*cols];
          }
          for (int i = 0; i &lt; rows; i++) {
              v_array[i] = 1;
              for (int j = 0; j &lt; cols; j++) {
                  array[i][j] = 1;
              }
          }
          for (int i = 1; i &lt; tot_pros; i++) {
              ch_size = (rows / (tot_pros - 1));
              start = (i - 1) * ch_size;
              if (((i + 1) == tot_pros) &amp;&amp; ((rows % (tot_pros - 1)) != 0)) {
                  close = rows;
              }
              else {
                  close = start + ch_size;
              }
              MPI_Send(&amp;start, 1, MPI_INT, i, 1, MPI_COMM_WORLD);
              MPI_Send(&amp;close, 1, MPI_INT, i, 2, MPI_COMM_WORLD);
              MPI_Send(&amp;cols, 1, MPI_INT, i, 4, MPI_COMM_WORLD);
              MPI_Send(&amp;array[start][0], ch_size *cols, MPI_INT, i, 3, MPI_COMM_WORLD);
          }
      }
      else
       {
          int cols;
          MPI_Recv(&amp;start, 1, MPI_INT, 0, 1, MPI_COMM_WORLD, MPI_STATUSES_IGNORE);
          MPI_Recv(&amp;close, 1, MPI_INT, 0, 2, MPI_COMM_WORLD, MPI_STATUSES_IGNORE);
          MPI_Recv(&amp;cols, 1, MPI_INT, 0, 4, MPI_COMM_WORLD, MPI_STATUSES_IGNORE);
          int **array = new int*[(close - start)*cols];
          MPI_Recv(array, (close - start) *cols , MPI_INT, 0, 3, MPI_COMM_WORLD, MPI_STATUSES_IGNORE);
          for (int i = start; i &lt; close; i++) {
              for (int j = 0; j &lt; cols; j++) {
                  cout &lt;&lt; array[i]&lt;&lt;array[j];
                      res += array[i][j] * v_array[i];
                      cout &lt;&lt; res;
                  }
              }
           }
      MPI_Finalize(); 
      return 0;
  }
  </code></pre>
  
  <p>This same program is working fine when I have static array, But with dynamic I got this error.</p>
  
  <blockquote>
    <p>E:\MS(CS)\2nd Semester\Parallel
    Programing\programs\arr_multi\Debug>mpiexec -n 4 arr_multi.exe Enter
    rows and columns: 3 2</p>
    
    <p>job aborted: [ranks] message</p>
    
    <p>[0-1] terminated</p>
    
    <p>[2] process exited without calling finalize</p>
    
    <p>[3] terminated</p>
    
    <p>---- error analysis -----</p>
    
    <p>[2] on RAMISHA-PC arr_multi.exe ended prematurely and may have
    crashed. exit code 0xc0000005</p>
    
    <p>---- error analysis -----</p>
  </blockquote>
  
  <p>I declared an array with contiguous location and my rows are divided correctly among processes. I think I have problem with my data structure and tried many solutions but in vain.</p>