Unhandled exception at 0x00E61A6C in testdll_1.exe: Stack cookie instrumentation code detected a stack-based buffer overrun.
Here’s what i’ve done, i’m doubting that some class like mat or Net caused this problem,
class ocr()
{
private:
Net net
public:
ocr(){net = readnetfromonnx(path)}
~ocr(){nothing here}
void recognizefunc1(Mat &mat1, Net &net, double &result)
}
I’m using Opencv4.5.3 x86 static lib with cmake3.21.2, vs2015,compiler should be default, windows8,the question has alse been discovered on other version. Some others said that the readNetFromonnx(“path”)would cause the memory location error
#include …(all opencv’s static lib in x86)
using namespace …
(…)dllexport ocr:
private:
Net net;
public:
ocr(){net= readNetFromONNX("./1.onnx")}
~ocr(){net.~Net()}
void showimg(string path){ Mat img = imread ; imshow() ; cv::waitKey;}
using the dll by coping it and #pragma comment (lib, …)
this still cause the problem of stack overrun.
I’ve just tried
ocr read;
return;
}
the function works fine, but after the return the error shows up, How so?
Any other ways to create a Net type and allocate memory location suggest? Thanks!(perhaps like getMemoryConsumption())
Hi, these indeed are my own built libs, I’ve tried debug with main contained only:
ocr read; (the class dllexported)
return;
and checked x86, release/debug, and the code I have was only 1 function with imshow(’’), I wasn’t even using this function. APPLICATION of this class without dll works fine.
it still goes: Run-Time Check Failure #2 - Stack around the variable 'read' was corrupted.
net.~Net seems not needed indeed, I’m doubting that the function readNetFromONNX() leads to this, but not the Net, Is it possible that link static libraries of opencv to a DLL would cause this.
I think I get your idea, which means build a simple app, However I’m trying to build a dll to handle it to someone else, which means it’s not right approach for me.
I’ve just found out a possible reason of the stack overrun error! while link Opencv’s static libs to a dll, opencv would like to use another heap(BUT NOT THE LOCAL HEAP). It’s like when I declare a Net/vector type, etc, in my dll, Opencv can’t run the destructor .
This would cause the memory location error,
which means Net net= readNetFromONNX(path) is probably a wrong way, Would you please show any way of solution of this?
Define like this wouldn’t help, Net net[300]
Maybe should I try pointer or just allocate memory to all similar function?
Using mfc in a static library would cause error of:
unresolved external symbol _imp_BitBlt@36, _imp_CombineRgn@16 and so on.
so I’m using standard windows libraries.
Is it possible that cut the header of makedll.hpp into makedll.cpp?
I’m wondering using opencv_world453.dll instead of static libs, I’ve heard that some static libs would cause not using local heap error.
Hi I have tried copied the hpp and it goes well!
But however this would lead to a problem,
What am I supposed to do If I have Net and Mat type in my class’s private?
What about other member functions that are I’m not willing to show to others
This made it impossible to exclude whole Opencv’s hpps while releasing my own dll.
THANKS for that suggestion, it helped indeed!!
I was trying to hide Mat type is because that the environment somebody going to use dll with is different from mine, who’s making the dll.
eg. I’m makeing dll with opencv4.5.3 which contains dnn module.
But the env using this would be opencv2 instead.
I’m able to hide Net type with class’s interface right now.
I’m wondering that is the Mat type being changed in previous version? Or maybe I should transfer a unsigned char* a = mat.data() and Its’ h,w,rgb_type instead?
I’m afraid that there would be a little difference while the mat meetings with different type around rgb,rbg, and gray type. It might be a little difficult to verify the img being transfered right or not without opencv.