title: Xcode: will only fail on 4 inch 64-bit device
body: <p>I'm building an iOS app in Xcode. I've run into an issue with my build. Specifically, when I run my app on my physical device (iPhone 5) and any simulated 32-bit device, it runs fine. But if I use the 4 inch 64bit device, I get the following error on a specific line of code:</p>
  
  <pre><code>Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
  </code></pre>
  
  <p>I'm guessing this error means nothing as I don't get it with any other device.</p>
  
  <p>I have tried cleaning my build and build folder, and even reverting to earlier commits that didn't have this issue. That didn't work (much to my surprise).</p>
  
  <p>When I first had this error, I had something along the lines of <a href="https://stackoverflow.com/questions/12672603/could-not-load-the-image-referenced-from-a-nib">this StackOverflow question</a> relating to images ("Could not load the "" image referenced from a nib in the bundle with identifier ..."). Specifically, I think my issue is a due to a copy-and-paste of a UIButton in Interface Builder. I have since deleted this button.</p>
  
  <p>How do I resolve this issue?</p>
  
  <p>When I run the program on the only simulated device that causes this problem, I get the following output on the console:</p>
  
  <pre><code>2014-03-16 16:35:54.922 iSparse[3743:60b] 
  (lldb)
  (lldb) p idx[0]
  (int) $0 = 35353
  (lldb) p idx[1]
  (int) $1 = 17508
  (lldb) p colorPlane[0]
  (float) $2 = 218
  (lldb) p y_r[0]
  (float) $3 = 0
  (lldb) p y_r[1]
  (float) $4 = 0
  </code></pre>
  
  <p>This tells me that <code>idx</code> and <code>colorPlane</code> appear to be valid arrays and since <code>y_r</code> is not filled with pixel values, that line of code not executed.</p>
  
  <p>The function where this error occurs is</p>
  
  <pre><code>-(void)makeMeasurements2:(UIImage *)image atRate:(float)rate
                       red:(float *)y_r green:(float *)y_b blue:(float *)y_g
                  ofLength:(int)length idx:(int *)idx{
      // vDSP_vgathr is equivalent to a[i] = b[c[i]] (!)
      int pix = image.size.height * image.size.width;
      float * array = (float *)malloc(sizeof(float) * pix * 4);
      float * colorPlane = (float *)malloc(sizeof(float) * pix);
      // get data
  
      [self.dwt imageToRawArray:image into:array pix:length];
      int n;
  
      // perform wavelet, 2D on image
      // using color planes, all of that
      // vDSP_vgathr is the equivalent of a[i] = b[c[i]]
      for (n=0; n&lt;3; n++) {
          // copy from "array", which is RGBA,RGBA,RGBA...
          // and get the colorplane out
          cblas_scopy(pix, array+n, 4, colorPlane, 1);
  
          // the do-what-you-want code should go here.
          if (n == 0) {
              vDSP_vgathr(colorPlane, (const vDSP_Length *)idx, 1, y_r, 1, (int)(rate*pix));
          }
          if (n == 1) {
              vDSP_vgathr(colorPlane, (const vDSP_Length *)idx, 1, y_b, 1, (int)(rate*pix));
          }
          if (n == 2) {
              vDSP_vgathr(colorPlane, (const vDSP_Length *)idx, 1, y_g, 1, (int)(rate*pix));
          }
          cblas_scopy(pix, colorPlane, 1, array+n, 4);
      }
  
      catlas_sset(pix, 255, array+3, 4);
  
      image = [self.dwt UIImageFromRawArray:array image:image forwardInverseOrNull:@"null"];
      free(array);
      free(colorPlane);
  </code></pre>
  
  <p>It fails on the first <code>vDSP_vgathr</code> in the for-loop.</p>