libcvd icon indicating copy to clipboard operation
libcvd copied to clipboard

convolveGaussian memory error with k by 2 images

Open deads opened this issue 8 years ago • 6 comments

The convolveGaussian function seems to have problems with k by 2 images.

Here is the backtrace:

free(): invalid next size (fast): 0x0000000001253990 ***

#0  0x00007ffff6d23bb9 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff6d26fc8 in __GI_abort () at abort.c:89
#2  0x00007ffff6d60e14 in __libc_message (do_abort=do_abort@entry=1, 
    fmt=fmt@entry=0x7ffff6e6f668 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007ffff6d6d0ee in malloc_printerr (ptr=<optimized out>, 
    str=0x7ffff6e6f808 "free(): invalid next size (fast)", action=1)
    at malloc.c:4996
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0)
    at malloc.c:3840
#5  0x00007fffed02b111 in deallocate (this=<synthetic pointer>, __p=0xce8990)
    at /usr/include/c++/5/ext/new_allocator.h:110
#6  deallocate (__a=<synthetic pointer>, __n=<optimized out>, __p=0xce8990)
    at /usr/include/c++/5/bits/alloc_traits.h:386
#7  _M_deallocate (this=<synthetic pointer>, __n=<optimized out>, __p=0xce8990)
    at /usr/include/c++/5/bits/stl_vector.h:178
#8  ~_Vector_base (this=<synthetic pointer>, __in_chrg=<optimized out>)
    at /usr/include/c++/5/bits/stl_vector.h:160
#9  ~vector (this=<synthetic pointer>, __in_chrg=<optimized out>)
    at /usr/include/c++/5/bits/stl_vector.h:425
#10 CVD::convolveGaussian_simd (I=..., out=..., sigma=sigma@entry=1, 
    sigmas=<optimized out>) at cvd_src/i686/convolve_gaussian.cc:149
#11 0x00007fffed02b524 in CVD::convolveGaussian (I=..., out=..., 
    sigma=sigma@entry=1, sigmas=sigmas@entry=3)
    at cvd_src/i686/convolve_gaussian.cc:398

Here are some of the fields in the offending image:

(const CVD::BasicImage<float> &) @0x7fffffffd880: {<CVD::Internal::ImageData<float, false>> = {my_data = 0x741a860, my_size = {x = 2, y = 591}, 
    my_stride = 2}

Please let me know if you need any more information. Thanks!

deads avatar Feb 23 '17 22:02 deads

Is this from a release or the latest point on the master branch?

-Ed

On 23 February 2017 at 22:42, Damian Eads [email protected] wrote:

The convolveGaussian function seems to have problems with k by 2 images.

Here is the backtrace:

free(): invalid next size (fast): 0x0000000001253990 ***

#0 0x00007ffff6d23bb9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 #1 0x00007ffff6d26fc8 in __GI_abort () at abort.c:89 #2 0x00007ffff6d60e14 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7ffff6e6f668 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175 #3 0x00007ffff6d6d0ee in malloc_printerr (ptr=, str=0x7ffff6e6f808 "free(): invalid next size (fast)", action=1) at malloc.c:4996 #4 _int_free (av=, p=, have_lock=0) at malloc.c:3840 #5 0x00007fffed02b111 in deallocate (this=, __p=0xce8990) at /usr/include/c++/5/ext/new_allocator.h:110 #6 deallocate (__a=, __n=, __p=0xce8990) at /usr/include/c++/5/bits/alloc_traits.h:386 #7 _M_deallocate (this=, __n=, __p=0xce8990) at /usr/include/c++/5/bits/stl_vector.h:178 #8 ~_Vector_base (this=, __in_chrg=) at /usr/include/c++/5/bits/stl_vector.h:160 #9 ~vector (this=, __in_chrg=) at /usr/include/c++/5/bits/stl_vector.h:425 #10 CVD::convolveGaussian_simd (I=..., out=..., sigma=sigma@entry=1, sigmas=) at cvd_src/i686/convolve_gaussian.cc:149 #11 0x00007fffed02b524 in CVD::convolveGaussian (I=..., out=..., sigma=sigma@entry=1, sigmas=sigmas@entry=3) at cvd_src/i686/convolve_gaussian.cc:398

Here are some of the fields in the offending image:

(const CVD::BasicImage &) @0x7fffffffd880: {<CVD::Internal::ImageData<float, false>> = {my_data = 0x741a860, my_size = {x = 2, y = 591}, my_stride = 2}

Please let me know if you need any more information. Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/edrosten/libcvd/issues/27, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGW6_8LTlXrGkkC2Isa4jICFDW-tKwWks5rfgtWgaJpZM4MKmM2 .

edrosten avatar Feb 26 '17 17:02 edrosten

It was from the master branch.

deads avatar Feb 27 '17 07:02 deads

Does it fail with a minimal example which does nothing but create an image and do a convolution?

sent from phone.

On 27 Feb 2017 07:05, "Damian Eads" [email protected] wrote:

It was from the master branch.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edrosten/libcvd/issues/27#issuecomment-282643608, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGW68HnTmESlnPWYQUdYPCdTbJJXiUMks5rgnWfgaJpZM4MKmM2 .

edrosten avatar Feb 27 '17 12:02 edrosten

Hi,

Here is a minimal example:

#include <cvd/image.h>
#include <cvd/convolution.h>

using namespace CVD;

int main(int argc, char **argv) {
  Image<float> img(ImageRef(2,5));
  Image<float> out(img.size());
  convolveGaussian(img, out, 1.0);
}

I compile with:

g++-5 -std=c++14 -lcvd test.cpp

When I run it, I get:

*** Error in `./a.out': free(): invalid pointer: 0x0000000001e844b0 ***

Aborted (core dumped)

deads avatar Feb 28 '17 01:02 deads

On 28 February 2017 at 01:23, Damian Eads [email protected] wrote:

Hi,

Here is a minimal example:

#include <cvd/image.h> #include <cvd/convolution.h>

using namespace CVD;

int main(int argc, char **argv) { Image img(ImageRef(2,5)); Image out(img.size()); convolveGaussian(img, out, 1.0); }

I compile with:

g++-5 -std=c++14 -lcvd test.cpp

When I run it, I get:

*** Error in `./a.out': free(): invalid pointer: 0x0000000001e844b0 ***

Thanks, I'll take a look.

-Ed

Aborted (core dumped)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edrosten/libcvd/issues/27#issuecomment-282911939, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGW61qyN7d9w2m-70E0dXuP6L_5PN1Nks5rg3cRgaJpZM4MKmM2 .

edrosten avatar Feb 28 '17 12:02 edrosten

OK, I have a partial fix at least. Not verified it fully, and I suspect there are other instances since it looks like there's a fair bit of copy/paste.

edrosten avatar Nov 29 '17 19:11 edrosten