Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convolveGaussian memory error with k by 2 images #27

Open
deads opened this issue Feb 23, 2017 · 6 comments
Open

convolveGaussian memory error with k by 2 images #27

deads opened this issue Feb 23, 2017 · 6 comments

Comments

@deads
Copy link
Collaborator

deads commented Feb 23, 2017

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!

@edrosten
Copy link
Owner

edrosten commented Feb 26, 2017 via email

@deads
Copy link
Collaborator Author

deads commented Feb 27, 2017

It was from the master branch.

@edrosten
Copy link
Owner

edrosten commented Feb 27, 2017 via email

@deads
Copy link
Collaborator Author

deads commented Feb 28, 2017

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)

@edrosten
Copy link
Owner

edrosten commented Feb 28, 2017 via email

@edrosten
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants