title: MPI Segmentation fault when using MPI_Bcast
body: <p>I'm trying to calculate the difference between the speedup and efficiency of broadcasting an array of 1 million integers to all processes using MPI_Bcast and the usual MPI_send and MPI_Recv. But I don't understand why I'm getting this segmentation fault, any help would be greatly appreciated. here is my code:</p>
  
  <pre><code>#define num_of_ints 1000000
  int *create_random_array(int);
  int main(int argc, char *argv[]){
  int size=0, my_rank =0, i=0;
  int tag =99;
  double start, end;
  int *array = NULL;
  srand(time(NULL));
  
  MPI_Status status;
  MPI_Init(&amp;argc, &amp;argv);
  MPI_Comm_size(MPI_COMM_WORLD, &amp;size);
  MPI_Comm_rank(MPI_COMM_WORLD, &amp;my_rank);
  
  if(my_rank ==0)
      array = create_random_array(size*num_of_ints);
  MPI_Barrier(MPI_COMM_WORLD);
  start = MPI_Wtime();
  MPI_Bcast(&amp;array, num_of_ints, MPI_INT, 0, MPI_COMM_WORLD);
  MPI_Barrier(MPI_COMM_WORLD);
  end = MPI_Wtime();
  printf("time of broadcast using Bcast is %f seconds", end - start);
  
  MPI_Barrier(MPI_COMM_WORLD);
  start = MPI_Wtime();
  if (my_rank == 0){
      for (i = 1; i &lt; size; i++)
          MPI_Send(&amp;array, num_of_ints, MPI_INT, i,tag, MPI_COMM_WORLD);
  }else{
      MPI_Recv(&amp;array, num_of_ints, MPI_INT, 0,tag,MPI_COMM_WORLD, &amp;status);
  }
  MPI_Barrier(MPI_COMM_WORLD);
  end = MPI_Wtime();
  
  printf("time of broadcast using send/recv is %f seconds", end - start);
  MPI_Finalize();
  return 0;
  }
   int *create_random_array(int size){
  int i=0;
  int *random_arr = (int*)malloc(size*sizeof(int));
  for(i=0;i&lt;size;i++)
      random_arr[i] = (rand()/(int)RAND_MAX);
  return random_arr;
   }
  </code></pre>