From: Chris Turnes on
I'm trying to write a c++ mex program that references the FFTW3 and NFFT3 libraries. When I mex compile, there are no errors and everything works fine. When I attempt to run the code, I get this exception, which terminates MATLAB:

------------------------------------------------------------------------
Segmentation violation detected at Thu Jun 3 13:57:09 2010
------------------------------------------------------------------------

Configuration:
MATLAB Version: 7.8.0.347 (R2009a)
Operating System: Linux 2.6.24-24-generic #1 SMP Fri Jul 24 22:46:06 UTC 2009 i686
GNU C Library: 2.7 stable
Window System: No active display
Current Visual: None
Processor ID: x86 Family 6 Model 7 Stepping 10, GenuineIntel
Virtual Machine: Java 1.6.0_04-b12 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode
Default Encoding: UTF-8

Fault Count: 1

Register State:
eax = 00000004 ebx = a0a323c0
ecx = 00000000 edx = ffffffff
esi = 00000004 edi = 08cbf6a8
ebp = b3604e68 esp = b3604e5c
eip = 00000000 flg = 00210296

Stack Trace:
[0] 0x00000000(4, 0xa0a5c11c, 0xb3604efc, 0xa0a42475)
[1] libfftw3.so.3:fftw_malloc~(4, 0x3ee4f8b5, 0xb3604e98, 0xb6e069ec ") + 29 bytes
[2] libnfft3.so.0:nfft_malloc~(0xb7f73ff4, 0xb6dfb7f4, 0xb6e9eb00, 0xb3604f50) + 85 bytes

The calling code is:
nfft_plan pn;
nfft_init_guru(&pn, 1, NN, h->R, n, 5,
PRE_PHI_HUT | PRE_FULL_PSI| MALLOC_F_HAT|MALLOC_X|MALLOC_F|FFTW_INIT| FFT_OUT_OF_PLACE,
FFTW_MEASURE| FFTW_DESTROY_INPUT);

I've checked all of the arguments for the nfft_init_guru, and they all seem to be fine. Does anyone know why fftw_malloc is raising a fit?