Re: [eigen] FFT question

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hope this is what you are asking for. Thanks for any insight, I know you all are very busy right now.

g++ -o min.o -c -I/home/tirons/src/eigen min.cpp
g++ -o min min.o

g++ --version
g++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1

tirons@baboon:~/sandbox/eigen$ gdb ./min
GNU gdb (GDB) 7.0-ubuntu
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/tirons/sandbox/eigen/min...done.
(gdb) run
Starting program: /home/tirons/sandbox/eigen/min
*** glibc detected *** /home/tirons/sandbox/eigen/min: free(): invalid next size (normal): 0x0000000000615790 ***
======= Backtrace: =========
/lib/libc.so.6[0x7ffff733add6]
/lib/libc.so.6(cfree+0x6c)[0x7ffff733f74c]
/home/tirons/sandbox/eigen/min[0x403a1f]
/home/tirons/sandbox/eigen/min[0x40555e]
/home/tirons/sandbox/eigen/min[0x404a97]
/home/tirons/sandbox/eigen/min[0x404424]
/home/tirons/sandbox/eigen/min[0x403f42]
/home/tirons/sandbox/eigen/min[0x403f5c]
/home/tirons/sandbox/eigen/min[0x40369d]
/lib/libc.so.6(__libc_start_main+0xfd)[0x7ffff72e3abd]
/home/tirons/sandbox/eigen/min[0x400f79]
======= Memory map: ========
00400000-00413000 r-xp 00000000 08:01 9937049                            /home/tirons/sandbox/eigen/min
00612000-00613000 r--p 00012000 08:01 9937049                            /home/tirons/sandbox/eigen/min
00613000-00614000 rw-p 00013000 08:01 9937049                            /home/tirons/sandbox/eigen/min
00614000-00635000 rw-p 00000000 00:00 0                                  [heap]
7ffff0000000-7ffff0021000 rw-p 00000000 00:00 0
7ffff0021000-7ffff4000000 ---p 00000000 00:00 0
7ffff72c5000-7ffff742b000 r-xp 00000000 08:01 753669                     /lib/libc-2.10.1.so
7ffff742b000-7ffff762a000 ---p 00166000 08:01 753669                     /lib/libc-2.10.1.so
7ffff762a000-7ffff762e000 r--p 00165000 08:01 753669                     /lib/libc-2.10.1..so
7ffff762e000-7ffff762f000 rw-p 00169000 08:01 753669                     /lib/libc-2.10.1.so
7ffff762f000-7ffff7634000 rw-p 00000000 00:00 0
7ffff7634000-7ffff764a000 r-xp 00000000 08:01 753698                     /lib/libgcc_s.so.1
7ffff764a000-7ffff7849000 ---p 00016000 08:01 753698                     /lib/libgcc_s.so.1
7ffff7849000-7ffff784a000 r--p 00015000 08:01 753698                     /lib/libgcc_s.so.1
7ffff784a000-7ffff784b000 rw-p 00016000 08:01 753698                     /lib/libgcc_s.so.1
7ffff784b000-7ffff78cd000 r-xp 00000000 08:01 753673                     /lib/libm-2.10.1.so
7ffff78cd000-7ffff7acd000 ---p 00082000 08:01 753673                     /lib/libm-2.10.1..so
7ffff7acd000-7ffff7ace000 r--p 00082000 08:01 753673                     /lib/libm-2.10.1.so
7ffff7ace000-7ffff7acf000 rw-p 00083000 08:01 753673                     /lib/libm-2.10.1..so
7ffff7acf000-7ffff7bc1000 r-xp 00000000 08:01 10265190                   /usr/lib/libstdc++.so.6.0.13
7ffff7bc1000-7ffff7dc1000 ---p 000f2000 08:01 10265190                   /usr/lib/libstdc++.so.6.0.13
7ffff7dc1000-7ffff7dc8000 r--p 000f2000 08:01 10265190                   /usr/lib/libstdc++.so.6.0.13
7ffff7dc8000-7ffff7dca000 rw-p 000f9000 08:01 10265190                   /usr/lib/libstdc++.so.6.0.13
7ffff7dca000-7ffff7ddf000 rw-p 00000000 00:00 0
7ffff7ddf000-7ffff7dfe000 r-xp 00000000 08:01 753666                     /lib/ld-2.10.1.so
7ffff7fcc000-7ffff7fcf000 rw-p 00000000 00:00 0
7ffff7ff9000-7ffff7ffc000 rw-p 00000000 00:00 0
7ffff7ffc000-7ffff7ffd000 r-xp 00000000 00:00 0                          [vdso]
7ffff7ffd000-7ffff7ffe000 r--p 0001e000 08:01 753666                     /lib/ld-2.10.1.so
7ffff7ffe000-7ffff7fff000 rw-p 0001f000 08:01 753666                     /lib/ld-2.10.1.so
7ffffffea000-7ffffffff000 rw-p 00000000 00:00 0                          [stack]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
Program received signal SIGABRT, Aborted.
0x00007ffff72f84b5 in *__GI_raise (sig=<value optimised out>)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64    ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
    in ../nptl/sysdeps/unix/sysv/linux/raise.c

// HERE IS BACKTRACE

(gdb) backtrace

#0  0x00007ffff72f84b5 in *__GI_raise (sig=<value optimised out>)
    at .../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff72fbf50 in *__GI_abort () at abort.c:92
#2  0x00007ffff7330c97 in __libc_message (do_abort=<value optimised out>,
    fmt=<value optimised out>) at ../sysdeps/unix/sysv/linux/libc_fatal.c:189
#3  0x00007ffff733add6 in malloc_printerr (action=""
    str=0x7ffff73fc720 "free(): invalid next size (normal)",
    ptr=<value optimised out>) at malloc.c:6217
#4  0x00007ffff733f74c in *__GI___libc_free (mem=<value optimised out>)
    at malloc.c:3716
#5  0x0000000000403a1f in Eigen::ei_aligned_free(void*) ()
#6  0x000000000040555e in void Eigen::ei_conditional_aligned_free<true>(void*)
    ()
#7  0x0000000000404a97 in void Eigen::ei_conditional_aligned_delete<double, true>(double*, unsigned long) ()
#8  0x0000000000404424 in Eigen::ei_matrix_storage<double, 33331, 33331, 1, 0>::~ei_matrix_storage() ()
#9  0x0000000000403f42 in Eigen::DenseStorageBase<Eigen::Matrix<double, 33331, 1, 0, 33331, 1>, Eigen::MatrixBase, 0>::~DenseStorageBase() ()
#10 0x0000000000403f5c in Eigen::Matrix<double, 33331, 1, 0, 33331, 1>::~Matrix() ()
#11 0x000000000040369d in main ()

// AND VALGRIND

tirons@baboon:~/sandbox/eigen$ valgrind ./min
==2556== Memcheck, a memory error detector
==2556== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==2556== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for copyright info
==2556== Command: ./min
==2556==
==2556== Invalid write of size 8
==2556==    at 0x406049: Eigen::ei_kissfft_impl<double>::inv(double*, std::complex<double> const*, int) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x404E11: Eigen::FFT<double, Eigen::default_fft_impl<double> >::inv(double*, std::complex<double> const*, int) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x4046C6: void Eigen::FFT<double, Eigen::default_fft_impl<double> >::inv<Eigen::Matrix<double, 33331, 1, 0, 33331, 1>, Eigen::Matrix<std::complex<double>, 33331, 1, 0, 33331, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 33331, 1, 0, 33331, 1> >&, Eigen::MatrixBase<Eigen::Matrix<std::complex<double>, 33331, 1, 0, 33331, 1> > const&) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x403690: main (in /home/tirons/sandbox/eigen/min)
==2556==  Address 0x59468b8 is 0 bytes after a block of size 408 alloc'd
==2556==    at 0x4C24356: memalign (vg_replace_malloc.c:532)
==2556==    by 0x4C243AF: posix_memalign (vg_replace_malloc.c:660)
==2556==    by 0x4039B7: Eigen::ei_aligned_malloc(unsigned long) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x407C60: void* Eigen::ei_conditional_aligned_malloc<true>(unsigned long) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x406E47: double* Eigen::ei_conditional_aligned_new<double, true>(unsigned long) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x405DCD: Eigen::ei_matrix_storage<double, 33331, 33331, 1, 0>::resize(int, int, int) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x404D7E: Eigen::DenseStorageBase<Eigen::Matrix<double, 33331, 1, 0, 33331, 1>, Eigen::MatrixBase, 0>::resize(int) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x404687: void Eigen::FFT<double, Eigen::default_fft_impl<double> >::inv<Eigen::Matrix<double, 33331, 1, 0, 33331, 1>, Eigen::Matrix<std::complex<double>, 33331, 1, 0, 33331, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 33331, 1, 0, 33331, 1> >&, Eigen::MatrixBase<Eigen::Matrix<std::complex<double>, 33331, 1, 0, 33331, 1> > const&) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x403690: main (in /home/tirons/sandbox/eigen/min)
==2556==
==2556== Invalid read of size 8
==2556==    at 0x4064BD: void Eigen::FFT<double, Eigen::default_fft_impl<double> >::scale<double*, double>(double*, double, int) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x404E58: Eigen::FFT<double, Eigen::default_fft_impl<double> >::inv(double*, std::complex<double> const*, int) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x4046C6: void Eigen::FFT<double, Eigen::default_fft_impl<double> >::inv<Eigen::Matrix<double, 33331, 1, 0, 33331, 1>, Eigen::Matrix<std::complex<double>, 33331, 1, 0, 33331, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 33331, 1, 0, 33331, 1> >&, Eigen::MatrixBase<Eigen::Matrix<std::complex<double>, 33331, 1, 0, 33331, 1> > const&) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x403690: main (in /home/tirons/sandbox/eigen/min)
==2556==  Address 0x59468b8 is 0 bytes after a block of size 408 alloc'd
==2556==    at 0x4C24356: memalign (vg_replace_malloc.c:532)
==2556==    by 0x4C243AF: posix_memalign (vg_replace_malloc.c:660)
==2556==    by 0x4039B7: Eigen::ei_aligned_malloc(unsigned long) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x407C60: void* Eigen::ei_conditional_aligned_malloc<true>(unsigned long) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x406E47: double* Eigen::ei_conditional_aligned_new<double, true>(unsigned long) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x405DCD: Eigen::ei_matrix_storage<double, 33331, 33331, 1, 0>::resize(int, int, int) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x404D7E: Eigen::DenseStorageBase<Eigen::Matrix<double, 33331, 1, 0, 33331, 1>, Eigen::MatrixBase, 0>::resize(int) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x404687: void Eigen::FFT<double, Eigen::default_fft_impl<double> >::inv<Eigen::Matrix<double, 33331, 1, 0, 33331, 1>, Eigen::Matrix<std::complex<double>, 33331, 1, 0, 33331, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 33331, 1, 0, 33331, 1> >&, Eigen::MatrixBase<Eigen::Matrix<std::complex<double>, 33331, 1, 0, 33331, 1> > const&) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x403690: main (in /home/tirons/sandbox/eigen/min)
==2556==
==2556== Invalid write of size 8
==2556==    at 0x4064C6: void Eigen::FFT<double, Eigen::default_fft_impl<double> >::scale<double*, double>(double*, double, int) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x404E58: Eigen::FFT<double, Eigen::default_fft_impl<double> >::inv(double*, std::complex<double> const*, int) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x4046C6: void Eigen::FFT<double, Eigen::default_fft_impl<double> >::inv<Eigen::Matrix<double, 33331, 1, 0, 33331, 1>, Eigen::Matrix<std::complex<double>, 33331, 1, 0, 33331, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 33331, 1, 0, 33331, 1> >&, Eigen::MatrixBase<Eigen::Matrix<std::complex<double>, 33331, 1, 0, 33331, 1> > const&) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x403690: main (in /home/tirons/sandbox/eigen/min)
==2556==  Address 0x59468b8 is 0 bytes after a block of size 408 alloc'd
==2556==    at 0x4C24356: memalign (vg_replace_malloc.c:532)
==2556==    by 0x4C243AF: posix_memalign (vg_replace_malloc.c:660)
==2556==    by 0x4039B7: Eigen::ei_aligned_malloc(unsigned long) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x407C60: void* Eigen::ei_conditional_aligned_malloc<true>(unsigned long) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x406E47: double* Eigen::ei_conditional_aligned_new<double, true>(unsigned long) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x405DCD: Eigen::ei_matrix_storage<double, 33331, 33331, 1, 0>::resize(int, int, int) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x404D7E: Eigen::DenseStorageBase<Eigen::Matrix<double, 33331, 1, 0, 33331, 1>, Eigen::MatrixBase, 0>::resize(int) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x404687: void Eigen::FFT<double, Eigen::default_fft_impl<double> >::inv<Eigen::Matrix<double, 33331, 1, 0, 33331, 1>, Eigen::Matrix<std::complex<double>, 33331, 1, 0, 33331, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 33331, 1, 0, 33331, 1> >&, Eigen::MatrixBase<Eigen::Matrix<std::complex<double>, 33331, 1, 0, 33331, 1> > const&) (in /home/tirons/sandbox/eigen/min)
==2556==    by 0x403690: main (in /home/tirons/sandbox/eigen/min)
==2556==
==2556==
==2556== HEAP SUMMARY:
==2556==     in use at exit: 0 bytes in 0 blocks
==2556==   total heap usage: 21 allocs, 21 frees, 16,104 bytes allocated
==2556==
==2556== All heap blocks were freed -- no leaks are possible
==2556==
==2556== For counts of detected and suppressed errors, rerun with: -v
==2556== ERROR SUMMARY: 27 errors from 3 contexts (suppressed: 4 from 4)


On 16 February 2010 00:13, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
This has got to be a bug in Eigen (possibly in KissFFT). Indeed,
you're getting a memory error without doing any explicity memory
management yourself.

Could you compile your program with -g3, paste a backtrace (obtained
with GDB), and also valgrind your program,
  valgrind ./myprogram
and paste the output here?

Benoit

2010/2/15 Trevor Irons <trevorirons@xxxxxxxxx>:
> Mark and others:
>
> I'm trying to get the KISS FFT working for me, but am struggling a little
> with the Real to Complex and back case. I suspect I'm misusing it somehow, I
> based this off the tests. The Complex to Complex fwd and inv (Full Spectrum)
> are working with similar logic.
>
> The forward operation seems to be accurate, but how do I do the inverse on
> 1/2 spectrum. If I don't remove the flag, I get a lot of errors at runtime
> (compiles fine):
>
> g++ on 64 bit linux
> *** glibc detected *** ./min: free(): invalid next size (normal):
> 0x0000000000da6790 ***
> ======= Backtrace: =========
> /lib/libc.so.6[0x7fc8a700cdd6]
> /lib/libc.so.6(cfree+0x6c)[0x7fc8a701174c]
>
> If I do remove the flag, thinking that maybe since the buffer is double, it
> will know it is a complex to real transform, but the answer is wrong.
>
> If a do a full spectrum all is happy.
>
> What am I doing wrong?  If possible I'd like to just use the 1/2 spectrum.
> Thanks for any insight, really glad to have this out of the box like this.
>
> #include "Eigen/Core"
> #include "unsupported/Eigen/FFT"
> #include <complex>
>
> typedef std::complex<double> Complex;
>
> using namespace Eigen;
> using namespace std;
>
> int main() {
>
>     FFT<double> fft;
>     double dt(1e-3);
>
>      VectorXd timeseries(200);
>      VectorXcd fd(200);
>
>      for (int i=0; i<200; ++i) {
>          timeseries[i] = std::sin((double)(i)*dt*95.);
>      }
>
>     fft.SetFlag(fft.HalfSpectrum );
>       fft.fwd(fd, timeseries);
>      VectorXd out;
>
>     // faults if I don't remove, wrong answer if I do
>      fft.ClearFlag(fft.HalfSpectrum );
>      fft.inv(out, fd);
>
>     for (int i=0; i< out.size(); ++i) {
>         cout << timeseries[i] << "\t" << out[i] << endl;
>     }
> }
>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/