Segmentation fault when reading image

I am getting segmentation fault. After using GDB I was able to get this stacktrace:

corrupted size vs. prev_size

Thread 41 "python" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fff7a79d700 (LWP 31422)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) where
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff7a248b1 in __GI_abort () at abort.c:79
#2  0x00007ffff7a6d907 in __libc_message (action=action@entry=do_abort, 
    fmt=fmt@entry=0x7ffff7b9adfa "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3  0x00007ffff7a7497a in malloc_printerr (
    str=str@entry=0x7ffff7b98efd "corrupted size vs. prev_size")
    at malloc.c:5350
#4  0x00007ffff7a74b7c in malloc_consolidate (av=av@entry=0x7ffe18000020)
    at malloc.c:4456
#5  0x00007ffff7a78848 in _int_malloc (av=av@entry=0x7ffe18000020, 
    bytes=bytes@entry=14055) at malloc.c:3703
#6  0x00007ffff7a7b35d in __GI___libc_malloc (bytes=14055) at malloc.c:3065
#7  0x00007fff99e57326 in ?? () from /usr/lib/x86_64-linux-gnu/
#8  0x00007fff99e5755e in ?? () from /usr/lib/x86_64-linux-gnu/
#9  0x00007fff9ca96f93 in cv::JpegDecoder::readData(cv::Mat&) ()
   from /usr/local/lib/
#10 0x00007fff9ca832b8 in cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) ()
   from /usr/local/lib/
#11 0x00007fff9d393bda in load_example (input_example=...)
    at /home/pislb/augmentations/cpp/augmentations.cpp:57

The line /home/pislb/augmentations/cpp/augmentations.cpp:57 is:

        cv::Mat image = cv::imread(image_path, cv::IMREAD_COLOR);

Can anyone help me with this?

Some additionall info: running on Linux, OpenCV version 4.2.0.

Thanks for the help :slight_smile:


you need to provide more information. what is the picture (upload it)? what are the contents of the image_path variable? what is the rest of the code leading up to that line? please reduce the code to the bare minimum that reproduces the issue.