Excerpts from Gabriel M. Beddingfield's message of 2011-01-28 04:00:51 +0100: > Hi James, > > You always know how to nerd snipe me! > > On Thursday, January 27, 2011 06:35:08 pm James Stone wrote: > > I have been working on the Neil tracker program recently, > > and hit a weird bug that seems to affect only my > > computer! I get a segfault when trying to use fft.h > > Not just you. It segfaults for me, too. Ubuntu 10.04 with Core Duo > processor. > > With the patch below (to fft.h) I detect that p2r and p2i overrun the > buffer when k==11, j==0, i==0. However, k was supposed to STOP when > it reached 11 = log(2048)/log(2). > > My guess is that is that the integer k is promoted to a float and the > comparison is performed. When I replace: > > for (k = 0, le = 2; k < log(fftFrameSize)/log(2.); k++) { > > with: > > long ITERS = log(fftFrameSize)/log(2.0) + 0.5; > for (k = 0, le = 2; k < ITERS; k++) { > > ...the code doesn't crash on me. Here's a sample program that > illustrates what's happening. > > /* BEGIN */ > #include <cmath> > #include <iostream> > using namespace std; > > #define ITERS (log(2048)/log(2.0)) > > int main(void) > { > long k; > > for( k=0 ; k < ITERS ; ++k ) { > cout << "k = " << k > << " ITERS = " << ITERS > << " diff = " << (ITERS - k) > << endl; > } > > return 0; > } > /* END */ > > Output on my machine: > > k = 0 ITERS = 11 diff = 11 > k = 1 ITERS = 11 diff = 10 > k = 2 ITERS = 11 diff = 9 > k = 3 ITERS = 11 diff = 8 > k = 4 ITERS = 11 diff = 7 > k = 5 ITERS = 11 diff = 6 > k = 6 ITERS = 11 diff = 5 > k = 7 ITERS = 11 diff = 4 > k = 8 ITERS = 11 diff = 3 > k = 9 ITERS = 11 diff = 2 > k = 10 ITERS = 11 diff = 1 > k = 11 ITERS = 11 diff = 4.80518e-16 > > Thanks, > Gabriel Interesting.. would you mind explaining how this can be? How can 11-11 yield 4.80518e-16? Do I understand it correctly: log(2048)/log(2.0) yields a float and for comparison k is implicitly cast to float as well. Why does the output of your test-Program still show "k = 11"? And why does it only happen on some machines? I'd play with it and try to figure out what's going on and how this kind of problem can be avoided, but the error doesn't appear here. Here's the output on my machine: k = 0 ITERS = 11 diff = 11 k = 1 ITERS = 11 diff = 10 k = 2 ITERS = 11 diff = 9 k = 3 ITERS = 11 diff = 8 k = 4 ITERS = 11 diff = 7 k = 5 ITERS = 11 diff = 6 k = 6 ITERS = 11 diff = 5 k = 7 ITERS = 11 diff = 4 k = 8 ITERS = 11 diff = 3 k = 9 ITERS = 11 diff = 2 k = 10 ITERS = 11 diff = 1 _______________________________________________ Linux-audio-user mailing list Linux-audio-user@xxxxxxxxxxxxxxxxxxxx http://lists.linuxaudio.org/listinfo/linux-audio-user