简体   繁体   English

来自Opencv Mat :: create的Segfault

[英]Segfault from Opencv Mat::create

I am getting a Segmentation fault from the following call to Mat::Create 我从以下对Mat :: Create的调用中遇到了细分错误

void PoissonBlend::blend(Mat& src, Mat& dst, Mat& mask, Mat& out){

  Mat outer(mask.rows, mask.cols, CV_8U);

When I run my program in gdb I can see that both rows and cols are valid, and I have tried several different data types, but no matter what I get a Segfault on this line. 当我在gdb中运行程序时,我可以看到行和列都有效,并且我尝试了几种不同的数据类型,但是无论我在这行中得到了Segfault还是什么。

My program defines several other Mats in main(), before the call to blend, and all of them work perfectly fine. 在调用blend之前,我的程序在main()中定义了其他几个Mats,它们都工作得很好。 Has anyone else ever run into this before? 有人遇到过吗? This error is driving me crazy, I cant find any difference between this call to create and any of the others in my program, yet this one fails every time. 这个错误使我发疯,我无法在创建调用和程序中的任何其他调用之间找到任何区别,但是每次都会失败。

My gdb output is: 我的gdb输出是:

Program received signal SIGSEGV, Segmentation fault.
_int_malloc (av=0x7ffff6fbe740 <main_arena>, bytes=307228) at malloc.c:3879


#0  _int_malloc (av=0x7ffff6fbe740 <main_arena>, bytes=307228) at malloc.c:3879
#1  0x00007ffff6c88fc5 in __GI___libc_malloc (bytes=307228) at malloc.c:2924
#2  0x00007ffff791594d in cv::fastMalloc(unsigned long) () from /usr/lib/libopencv_core.so.2.3
#3  0x00007ffff78884bc in cv::Mat::create(int, int const*, int) () from /usr/lib/libopencv_core.so.2.3
#4  0x00000000004243da in cv::Mat::create (this=0x7fffffffdab0, _rows=480, _cols=640, _type=0) at /usr/include/opencv2/core/mat.hpp:368
#5  0x0000000000427608 in cv::Mat::Mat (this=0x7fffffffdab0, _rows=480, _cols=640, _type=0) at /usr/include/opencv2/core/mat.hpp:68
#6  0x00000000004255a7 in PoissonBlend::blend (this=0x7fffffffdd13, src=..., dst=..., mask=..., out=...)
 at /home/adam/WorkingCode/rasc/trunk/src/Poisson.cpp:95
#7  0x0000000000423eb2 in main () at    /home/adam/WorkingCode/rasc/trunk/src/PoissonTest.cpp:45

Since the crash is within malloc.c, I suspect that you probably have memory corruption. 由于崩溃位于malloc.c中,因此我怀疑您可能存在内存损坏。 Try running the program under Valgrind to detect this. 尝试在Valgrind下运行该程序以检测到此情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM