2

I'm trying to recompile a program that uses fftw3 (version 3.2.2) and already runs on a 32-bit linux machine. It compiles correctly on a 64-bit machine - and I linked to the 64-bit fftw library - but the program segfaults when trying to fftw_malloc. Below is the code used:

//the variables on the right side are already initialized to nonzero values
int olsLen = blockLen + tempLen - 1;
int num_chans = 23;

fftw_complex *gabor_filter, *block_signal, *ols_out;

gabor_filter = (fftw_complex *) fftw_malloc( olsLen
                                             * num_chans
                                             * sizeof(fftw_complex));

block_signal = (fftw_complex *) fftw_malloc( olsLen
                                             * num_chans
                                             * sizeof(fftw_complex));

ols_out = (fftw_complex *) fftw_malloc( olsLen
                                        * num_chans
                                        * sizeof(fftw_complex));

It seems like the problem should be obvious to find, but I'm too daft to see my error at the moment. Any ideas?

EDIT: It segfaults on the first fftw_malloc. In this case, it's gabor_filter, but if I reorder the variables, the program will segfault on the first fftw_malloc.

  • On which fftw_malloc call does the program segfault? Seems like a stupid question seeing as each call is the same. – ctor Jul 12 '12 at 18:56
  • forgot to mention that. it segfaults on gabor_filter, but if reorder the variables, whatever is first segfaults (i.e., when block_signal is first, that will segfault) – user1521731 Jul 12 '12 at 19:13
  • Can you try [`fftw_complex *fftw_alloc_complex(size_t n);`](http://www.fftw.org/doc/Memory-Allocation.html) instead and see what happens? It is a convenience function for allocating complexes. Just curious to know what happens then. – ArjunShankar Jul 12 '12 at 19:20
  • I get a compile error: In member function FtrCalc_Rasta::Process_Gabor(...) error: expected primary expression before '*' token //the first fftw_alloc_complex line error: 'fftw_alloc_complex' is not defined in this scope – user1521731 Jul 12 '12 at 21:41

1 Answers1

0

Looks like you will need to upgrade to 3.3.3. I'm not sure why your setup isn't working but fftw_alloc_complex() wasn't added until 3.3-beta1:

New convenience functions fftw_alloc_real and fftw_alloc_complex to use fftw_malloc for real and complex arrays without typecasts or sizeof.

FFTW 3 release notes

After you upgrade, does this still happen? (either your original question or the response to @ArjunShankar 's comment)

tir38
  • 9,810
  • 10
  • 64
  • 107