Question

On sporadic occasions I'm getting an EXC_BAD_ACCESS (SIGSEV) in one of Apple's Accelerator framework methods, vDSP_fft2d_zip. The crash report gave the following for Thread 10. Again, most of the time this works like a champ. Any ideas on how to find the cause and fix it?

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x412f2740
Triggered by Thread:  10
. . .

Thread 10 Crashed:
0   libvDSP.dylib                   0x2ddfcdb4 ___lldb_unnamed_function431$$libvDSP.dylib + 68
1   libvDSP.dylib                   0x2ddfab66 ___lldb_unnamed_function427$$libvDSP.dylib + 562
2   libvDSP.dylib                   0x2ddfa8ee vDSP_fft2d_zop + 434
3   libvDSP.dylib                   0x2ddfa732 vDSP_fft2d_zip + 18
4   ASSIST for iPad                 0x000ac32e -[Processor setupFilterForBubbleSizeMM:rectWidth:rectImageWidth:dataFilled:dataUnfilled:] (Processor.mm:813)
5   ASSIST for iPad                 0x000af4d2 -[Processor runConvolutionProcessOnImage:aveImage:] (Processor.mm:1835)
6   ASSIST for iPad                 0x000ac5f6 -[Processor processAnswers] (Processor.mm:869)
7   ASSIST for iPad                 0x000ae9cc -[Processor process] (Processor.mm:1644)
8   ASSIST for iPad                 0x000d7744 -[ReallTimeScanner processImage:] (ReallTimeScanner.mm:1046)
9   Foundation                      0x2f296c82 __NSThread__main__ + 1058
10  libsystem_pthread.dylib         0x396b6c1a _pthread_body + 138
11  libsystem_pthread.dylib         0x396b6b8a _pthread_start + 98
12  libsystem_pthread.dylib         0x396b4c8c thread_start + 4

The relevant code looks like this:

#define FFT_SIZE 512
#define FFT_POWER 9

dataFilledIn->imagp=(float *) malloc(sizeof(float)*FFT_SIZE*FFT_SIZE);
dataFilledIn->realp=(float *) malloc(sizeof(float)*FFT_SIZE*FFT_SIZE);
dataUnfilledIn->imagp=(float *) malloc(sizeof(float)*FFT_SIZE*FFT_SIZE);
dataUnfilledIn->realp=(float *) malloc(sizeof(float)*FFT_SIZE*FFT_SIZE);

memset(dataFilledIn->imagp, 0, sizeof(float)*FFT_SIZE*FFT_SIZE);
memset(dataFilledIn->realp, 0, sizeof(float)*FFT_SIZE*FFT_SIZE);
memset(dataUnfilledIn->imagp, 0, sizeof(float)*FFT_SIZE*FFT_SIZE);
memset(dataUnfilledIn->realp, 0, sizeof(float)*FFT_SIZE*FFT_SIZE);


for(float y=0; y<FFT_SIZE; y+=0.25)
{
    for(float x=0; x<FFT_SIZE; x+=0.25)
    {
        dataFilledIn->realp[(int)y*FFT_SIZE+(int)x] += 0.0625;
        dataUnfilledIn->realp[(int)y*FFT_SIZE+(int)x] -= 0.0625;
    }
}

vDSP_fft2d_zip(setup, dataFilledIn, 1, 0, FFT_POWER, FFT_POWER, kFFTDirection_Forward);
Was it helpful?

Solution

Answering my own question here: Be sure that the very first parameter sent in (type FFTSetup) to vDSP_fft2d_zip() is initialized correctly, and you should use this call

vDSP_destroy_fftsetup(setup);

to clean it up. I was initializing the setup var properly, like this

setup = vDSP_create_fftsetup(FFT_POWER, kFFTRadix2);

and then cleaning it up, but then was not initializing it again before subsequent calls to vDSP_fft2d_zip(). Unfortunately it only rarely caused a crash, which made it seem like the frequent calls to vDSP_fft2d_zip(setup, . . .) were working when they weren't. The crashes were sporadic making the real cause hard to trace.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top