title: Xcode __pthread_kill + 20
body: <p>I am trying to run simple command line application with large array, it works if I try looping through 30 rows of the array, but when I increase it to 1000 it crashes, showing (lldb) in the console. Under thread 1 I have __pthread_kill , __stack_chk_fail .  My code: </p>
  
  <pre><code>int main(int argc, const char * argv[]) {
  
  
  int i;
  int j;
  int x;
  
  
  int mains [2][50]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,
      31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50};
  int stars [2][11]={1,2,3,4,5,6,7,8,9,10,11};
  
  int results [1000][7]={
  
      {27,29,37,39,49,2,4}, //03.04.2015
  
      {8,20,24,28,49,8,9},
  
   // rest of array not relevant to the problem
  
      {16,29,32,36,41,7,9},
  
  };
  
  
  
  for (i=0; i&lt;1000; i++)
  {
      for (j=0; j&lt;5; j++)
      {
          for (x=0; x&lt;51; x++)
          {
              if (results[i][j]==mains[0][x])
              {
                  mains[1][x]++;
              }
          }
  
      }
  }
  
  for (i=0; i&lt;1000; i++)
  {
      for (j=5; j&lt;7; j++)
      {
          for (x=0; x&lt;12; x++)
          {
              if (results[i][j]==stars[0][x])
              {
                  stars[1][x]++;
              }
          }
  
      }
  }
  
  
  
  for (i=0; i&lt;49; i++)      //array sorting
  {
      for (j=i+1; j&lt;50; j++)
      {
          if (mains[1][i]&gt;mains[1][j])
          {
              std::swap(mains[0][i],mains[0][j]);
              std::swap(mains[1][i],mains[1][j]);            }
      }
  
  }
  
  for (i=0; i&lt;10; i++)      //array sorting
  {
      for (j=i+1; j&lt;11; j++)
      {
          if (stars[1][i]&gt;stars[1][j])
          {
              std::swap(stars[0][i],stars[0][j]);
              std::swap(stars[1][i],stars[1][j]);            }
      }
  
  }
  
  
  
  
  printf("Mains        Stars:\n\n");
  for (i=0; i&lt;5; i++)
  {
      printf("%d ",mains[0][i]);
  }
  
  for (i=0; i&lt;2; i++)
  {
      printf("%d ",stars[0][i]);
  }
  
  
  return 0;
  }
  </code></pre>