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:
Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
I'm guessing this error means nothing as I don't get it with any other device.
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).
When I first had this error, I had something along the lines of this StackOverflow question 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.
How do I resolve this issue?
When I run the program on the only simulated device that causes this problem, I get the following output on the console:
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
This tells me that idx
and colorPlane
appear to be valid arrays and since y_r
is not filled with pixel values, that line of code not executed.
The function where this error occurs is
-(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<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);
It fails on the first vDSP_vgathr
in the for-loop.