Access violation reading location 0xcccccccc - c++

I am trying to run the squares.cpp example in the openCV 2.2. The code compiles and builds without errors in Visual Studio 2008. However when I run the executable (i.e., during run time) I am getting a error stating
Unhandled exception at 0x004ac363 in OpenCVRectangle.exe: 0xC0000005: Access violation reading location 0xcccccccc.
This occurs at the definition:
vector<vector<Point> > squares;
in the main function
Can somebody help, why this occurs?
I figured out that the value 0xcccccc usually is an uninitialized or bad variable, but do not understand why I get this exception at this line.
The full example code can be found at http://pastebin.com/MTaXVcQz

Your code runs fine on Mac OS X with OpenCV 2.3.0, but OpenCV is known to present different behaviors in different Operating Systems.
First, check if your code has this problem in both Release and Debug versions.
Upgrade to OpenCV 2.3.1 on Windows and see if the problem goes away.

namedWindow in the code you linked to is a function which doesn't look defined in this scope. It might be that it's trying to interpret as a variable which has not been defined, rather than a function. I would say it's missing some sort of library perhaps? It's difficult to say without further context, but vector<vector<Point> > squares; should not be a violation.

Press Ctrl + Alt + E in VS, enable all exceptions checking, run it in debug mode and see the place where the exception is rised. This should be enough for understanding.

Related

Facing some issues in debugging ASIFT algorithm in C++ on Visual Studio 2019

Hope you are well and safe. I found an implementation of ASIFT in C++ online(http://www.mattsheckells.com/opencv-asift-c-implementation/). But for some reason, i am getting errors during runtime. I have tried and tested the same on 32 bit version with an older opencv(2.4.9), it is running fine however its slow. Now I want to test it on new opencv versions (3x,4x) but till now no success. I am using VS 2019 and compiling opencv using cmake in windows. For Opencv 3.x to access sift libraries, i am using opencv_contrib of the same version and compiling together. But there are no conclusive results. I hope you can guide me on this. I can let you know how i set things up in further edits.
The exact step where the debugging fails and error have been posted here.
//cv::xfeatures2d::SiftFeatureDetector detector;
Ptr<cv::xfeatures2d::SiftFeatureDetector> detector = makePtr<cv::xfeatures2d::SiftFeatureDetector>();
//Ptr<cv::xfeatures2d::SiftFeatureDetector> detector = cv::xfeatures2d::SiftFeatureDetector::create();
//detector.detect(timg, kps, mask);
detector->detect(timg, kps, mask);---- the program stops debugging error due to a memory error
"Unhandled exception at 0x00007FFDEC899709 in Project1_asift.exe: Microsoft C++ exception: cv::Exception at memory location 0x000000E5A319DDB8."
and i get this printed on the console:
"OpenCV(3.4.2) Error: The function/feature is not implemented () in cv::Feature2D::detectAndCompute, file c:\build\3_4_winpack-build-win64-vc15\opencv\modules\features2d\src\feature2d.cpp, line 154"
Hope to get a positive response.

Visual Studio C++ Cannot load Symbols and access violation when debugging

I am having a very strange issue. I have a c++ project that was working just fine until today. Today I tried to run the visual studio debugger and at the very beginning of the main function, I get an access violation exception. The line where the exception occurs varies, though it is always in the first few lines of my main function. Visual studio claims the source file is not available.
I'm not sure what changed, although recently, upon opening the visual studio project, I was presented with a message about finding a suitable location for he pdb, which i naively clicked "ok" to.
In case this helps, the call stack is:
ntdll.dll!_RtlInitUnicodeStringEx#8()
KernelBase.dll!LoadLibraryExW()
KernelBase.dll!_LoadLibraryW#4()
kernel32.dll!#BaseThreadInitThunk#12()
ntdll.dll!__RtlUserThreadStart()
ntdll.dll!__RtlUserThreadStart#8()
Edit:
I tried a new empty project. Literally:
// TestProj.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main()
{
return 0;
}
and I get a similar error.

memcpy.asm not found error

I am working in Optix Using Visual studio 2013 platform, I have been working over month , suddenly I got this error, "memcpy.asm not found".
I found this file in Visual studio folder but it says "The source file is different from when the module was built"
Look carefully at the error, often this comes up as a secondary message because the debugger is trying to load "memcpy.asm" in order to show you debugging information because a memcpy failed, not because your program is actually missing "memcpy.asm"
Heres someone with a similar issue, in short - check the stack trace to see where the issue originated in your code, probably with trying to copy memory to an uninitialized pointer or something.

Debug Assertion Failed - DirectShow Filter calling OpenCV Function - Release mode only

I am programming a DirectShow Filter that detects objects with an OpenCV HaarcascadeClassifier. It is working fine in Debug mode but not in Release mode and I'm not sure whether there is an memory leak in the OpenCV function (VC 2010 binary of opencv_249 libs) or whether there is something wrong with my project (settings).
I am loading the filter in GraphStudio, a tool to build a DirectShow FilterGraph easily. I'm not sure whether there are assumptions about the filter DLL to be compiled in Debug mode or not.
I'm basically doing the following, after some preprocessing:
std::vector<cv::Rect> objects;
mClassifier.detectMultiScale(inputGray,objects, 1.3);
for(unsigned int i=0; i<objects.size(); ++i)
{
cv::rectangle(outputImage, objects[i], cv::Scalar(255,255,255));
}
So within the function block I am preprocessing, followed by the shown part of code and followed by writing the data to the DirectShow Buffer.
If I use the DLL in Release mode, I get the following error message AFTER the whole function terminated (so probably somewhere else inside the DirectShow Filtergraph):
Debug Assertion Failed!
Program: C:\Program Files (x86)\Graphstudio\graphstudio.exe
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp
Line: 52
Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
For information [...]
followed by a
Debug Assertion Failed!
Program: C:\Program Files (x86)\Graphstudio\graphstudio.exe
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp
Line: 1322
Expression: _CrtlsValidHeapPointer(pUserData)
When I comment mClassifier.detectMultiScale(inputGray,objects, 1.3); out, the filter doesn't crash. Though some things might be optimized away, I replaced the detectMultiScale call with a loop that randomly (previously seeded with time(NULL)) inserts cv::Rect objects into the vector. The filter does not crash and displays the random rectangles in the way I would assume.
I've read that others have observed (valgrind) cv::CascadeClassifiert::detectMultiScale to produce memory leaks. And I've found a link where someone had a problem with detectSingleScale and some OpenCV committer marked it to be fixed ( http://code.opencv.org/issues/2628 ).
Questions:
Is there a chance that this exact problem (see previous link) is (still) within detectMultiScale?
Is there a chance that the problem is not within my project, but in the OpenCV library?
Why does this problem only occur in Release mode?
Why does this problem only occur in the DirectShow filter? (if I run the "same" code/functionality in Release mode in a stand-alone project, I don't get Debug Assert Failed errors - though there might be a unrecognized memory corruption?!?).
I hope someone has an idea and thx in advance!
EDIT:
ok... I had linked against msvcrtd.lib ... removed the whole lib from my project (seems I didnt even need it) and it "works" now... There is the question left, whether there is some kind of memory leak. Or was linking against that lib the only whole problem?
ok... I had linked against msvcrtd.lib ...
removed the whole lib from my project (so default libs are added?!?) and it "works" now...
There is the question left, whether there is some kind of memory leak.
Or was linking against that lib the only whole problem?
stupid me...

Panda3D and load_model c++

I am new to panda3d and am trying the hello world.
I have gotten the program to run with just:
PandaFramework framework;
framework.open_framework(argc, argv);
WindowFramework *window = framework.open_window();
framework.main_loop();
framework.close_framework();
return 0;
however, if I add in :
NodePath environt = window->load_model(framework.get_models(), "panda-model");
environt.reparent_to(window->get_render());
environt.set_scale(0.25, 0.25, 0.25);
environt.set_pos(-8, 42, 0);
before the main_loop(), it won't compile. I have the panda-model.egg.pz in every folder of my c++ project but every time my program breaks on :
environt.reparent_to(window->get_render());
The excat message is: Unhandled exception at 0x0152a317 in Irr.exe: 0xC00001A5: An invalid exception handler routine has been detected.
It compiles fine the only wraning being that it can't find the pdb files but that doesn't matter.
Any ideas?
Btw, im using MSVC++ 2010 and panda3d 1.7.2
The only error I can find is : First-chance exception at 0x00bfa317 in Irr.exe: 0xC0000005: Access violation reading location 0x737265db.
Unhandled exception at 0x00bfa317 in Irr.exe: 0xC00001A5: An invalid exception handler routine has been detected.
The program '[8476] Irr.exe: Native' has exited with code 0 (0x0).
which I'm pretty sure is still rather vague. I'm sorry but its all I can find. I'd be happy to describe it more though if necessary.
Microsoft Visual C++ 2010 is not supported by current versions of Panda3D. You will need to use 2008 or compile the Panda3D SDK from source against MSVC 2010. (This is not as straightforward as it sounds, as you will also need to compile some of the thirdparty packages to be compatible with 2010. However, it is possible.)
If you insist on using 2010 instead of 2008, this forum post may be helpful:
https://www.panda3d.org/forums/viewtopic.php?t=12663