How To Solved Unhandled exception at 0x000000013F88FF02 in testvision.exe: 0xC0000005: Access violation reading location 0x0000000005749000

-2

when I tried to start using Libre CVblob and I tried to detect the use of CVblob I found it.

this is break message:

Unhandled exception at 0x000000013F88FF02 in testcvblob.exe: 0xC0000005: Access violation reading location 0x0000000005749000.

this is message description :

+       endPoint    {x=??? y=??? }  cv::Point_<int>
+       startPoint  {x=??? y=??? }  cv::Point_<int>
+       this    0x000001e000000280 {parent=??? labels=??? currentLabel=??? ...} myCompLabeler *

and this is the intended program in liblary cvbloblib component labeling:

for(c=startPoint.x+1;c<endPoint.x-1;c++){
            pos = r*w+c;
            if(ptrDataBinary[pos]){
                label = ptrDataLabels[pos];
                if(label!=0)
                    currentBlob = label->parent;
                else if(!ptrDataBinary[pos-1]){
                    currentBlob = new CBlob(currentLabel,Point(c,r),Size(w,h));
                    blobs.push_back(currentBlob);
                    TracerExt();
                }
                if(!ptrDataBinary[pos+1] && ptrDataLabels[pos+1]==0){
                    TracerInt();
                }
            }
        }
c++
visual-studio
opencv
visual-studio-2012
cvblobslib
asked on Stack Overflow Oct 24, 2018 by Muhammad Ali Hasan Khatami Sin • edited Oct 24, 2018 by Jesper Juhl

1 Answer

0

It's been a while since i've used Microsoft Visual Studio, but I remember that 0xC0000005 is a segmentation fault. That means you are accessing program data that doesn't belong to you.

Without seeing more of the code, it's hard to determine where exactly that happens, but typically this happens when:

1) You access array indices that don't exist. So you need to check the size of the array, ptrDataLabels and you need to check that pos, pos+1 are all less than the size of it. Check that pos-1 is always 0 or greater, as an array index of -1 is bad also.

2) Another is that you're derefencing data that doesn't exist. For example, take the pointer, "label" in your function. You've checked that it's not null, that is good. But it may be uninitialised (i cannot tell from the code), if it's unitialised, dereferencing to a memberfunction will nearly always work [although is bad practice as it is undefined behaviour, as the comment below points out], but dereferencing it to data, wont be fine.

3) Another possibility is that you're executing this member function within a class that's been freed, is null, or is uninitialised. Yes that can happen. In which case, your function will execute fine, but if it accesses any data within the class that isn't a function, it can crash at any time.

A good thing to do here would be to set a breakpoint in this function and step through it. Looking for uninitialised variables and see the size of arrays, and if pointers like labels contain anything.

answered on Stack Overflow Oct 24, 2018 by Owl • edited Oct 26, 2018 by Owl

User contributions licensed under CC BY-SA 3.0