rageworx / libsrcnn

Super-Resolution imaging with Convolutional Neural Network library for G++, Non-OpenCV model.
http://rageworx.pe.kr/search/SRCNN
GNU Lesser General Public License v3.0
16 stars 1 forks source link

Memory error on Linux x86.64 v18.3 #8

Closed rageworx closed 5 years ago

rageworx commented 5 years ago

Error occurs on Linux Mint 18.3 from doSRCNN(), belong to resetImgF32().

0x00007ffff5568428 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:54
54  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) backtrace
#0  0x00007ffff5568428 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff556a02a in __GI_abort () at abort.c:89
#2  0x00007ffff55aa7ea in __libc_message (do_abort=do_abort@entry=2, 
    fmt=fmt@entry=0x7ffff56c3ed8 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007ffff55b337a in malloc_printerr (ar_ptr=<optimized out>, 
    ptr=<optimized out>, str=0x7ffff56c0caf "free(): invalid pointer", 
    action=3) at malloc.c:5006
#4  _int_free (av=<optimized out>, p=<optimized out>, have_lock=0)
    at malloc.c:3867
#5  0x00007ffff55b753c in __GI___libc_free (mem=<optimized out>)
    at malloc.c:2968
#6  0x00007ffff7bcacb9 in libsrcnn::resetImgF32(libsrcnn::ImgF32&) ()
   from /usr/local/lib/libsrcnn.so
#7  0x00007ffff7bcb624 in libsrcnn::doSRCNN(unsigned char const*, unsigned int, unsigned int, unsigned int, float, unsigned char*&, unsigned int&, unsigned char**, unsigned int*) () from /usr/local/lib/libsrcnn.so
#8  0x00007ffff7bcbb4f in ProcessSRCNN(unsigned char const*, unsigned int, unsigned int, unsigned int, float, unsigned char*&, unsigned int&, unsigned char**, unsigned int*) () from /usr/local/lib/libsrcnn.so
#9  0x000000000040888a in main (argc=3, argv=0x7fffffffde38)
    at src/test.cpp:726
rageworx commented 5 years ago

Backtracing ...

__GI___libc_free (mem=0x2a00000029) at malloc.c:2951
2951    malloc.c: No such file or directory.
(gdb) backtrace
#0  __GI___libc_free (mem=0x2a00000029) at malloc.c:2951
#1  0x0000000000409847 in libsrcnn::resetImgF32 (img=...)
    at src/libsrcnn.cpp:134
#2  0x0000000000409ad5 in libsrcnn::discardImgYCbCr (img=...)
    at src/libsrcnn.cpp:188
#3  0x000000000040a518 in libsrcnn::doSRCNN (
rageworx commented 5 years ago

This bug was belong to initImgYCbCr(). Solved bug by changing code.

192 void initImgYCbCr( ImgYCbCr &img, unsigned w, unsigned h, unsigned d )
193 {
194     initImgF32( img.Y, w, h );
195     initImgF32( img.Cb, w, h );
196     initImgF32( img.Cr, w, h );
197 
198     if ( d == 4 )
199     {
200         img.uA = true;
201         initImgF32( img.A, w, h );
202     }
203     else
204     {
205         memset( &img.A, 0, sizeof( ImgF32 ) );
206     }
207 }