aligned_free : invalid pointer when invoking resize
Summary
Segfault when invoking aligned_free
Environment
- Operating System : Linux
- Architecture : x64
- Eigen Version : 3.3.9
- Compiler Version : g++ 10.3.0
Minimal Example
//show your code hereSteps to reproduce
- first step
- second step
- ...
What is the current bug behavior?
Segfault with invalid pointer when attempting to resize (from setZero)
This is the code which is executed :
y.setZero(hNew.rows(), hNew.cols());
https://github.com/flatmax/gtkiostream/blob/master/src/DSP/FIR.C#L84
This is the dynamic sized member variable :
Eigen::Matrix<FP_TYPE, Eigen::Dynamic, Eigen::Dynamic> y;
https://github.com/flatmax/gtkiostream/blob/master/include/DSP/FIR.H#L67
What is the expected correct behavior?
No Segault, the matrix is resized and zeroed.
Relevant logs
gdb backtrace :
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  0x00007ffff782e864 in __GI_abort () at abort.c:79
#2  0x00007ffff7891736 in __libc_message
    (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff79b6b9c "%s\n")
    at ../sysdeps/posix/libc_fatal.c:155
#3  0x00007ffff789a08c in malloc_printerr
    (str=str@entry=0x7ffff79b4dcd "free(): invalid pointer") at malloc.c:5628
#4  0x00007ffff789baac in _int_free
    (av=<optimised out>, p=<optimised out>, have_lock=0) at malloc.c:4398
#5  0x00007ffff789f7a8 in __GI___libc_free (mem=<optimised out>)
    at malloc.c:3309
#6  0x00007ffff77df3ed in Eigen::internal::aligned_free(void*)
    (ptr=<optimised out>)
    at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:177
#7  Eigen::internal::conditional_aligned_free<true>(void*)
    (ptr=<optimised out>)
    at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:230
#8  Eigen::internal::conditional_aligned_delete_auto<double, true>(double*, unsigned long) (size=<optimised out>, ptr=<optimised out>)
    at /usr/include/eigen3/Eigen/src/Core/util/Memory.h:416
#9  Eigen::DenseStorage<double, -1, -1, -1, 0>::resize(long, long, long)
    (cols=2, rows=38400, size=76800, this=0x7fffffffdf68)
    at /usr/include/eigen3/Eigen/src/Core/DenseStorage.h:406
#10 Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::resize(long, long) (cols=2, rows=38400, this=0x7fffffffdf68)
    at /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:293
#11 Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::setZero(long, long) (cols=2, rows=38400, this=0x7fffffffdf68)
    at /usr/include/eigen3/Eigen/src/Core/CwiseNullaryOp.h:535Edited  by Matt Flax