Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory error #4

Open
ArsenLuca opened this issue Jul 4, 2018 · 8 comments
Open

memory error #4

ArsenLuca opened this issue Jul 4, 2018 · 8 comments

Comments

@ArsenLuca
Copy link

When I use the following image as input, the algorithm meets with a memory error in function
int EDLineDetector::EDline(image_int8u_p image, LineChains &lines, bool smoothed)
It seems to be a memory out of range error.
@frotms Could you please have a try and resolve the problem?
2

@frotms
Copy link
Owner

frotms commented Jul 4, 2018

@ArsenLuca ,
What is the error info?

@ArsenLuca
Copy link
Author

@frotms
In Linux Eclipse C++ IDE, it shows:
malloc(): memory corruption(fast): 0x0000000002145150 ***
In Visual Studio IDE, it shows error in delete function or sometimes malloc function.

@ArsenLuca
Copy link
Author

@frotms
you can have a try using the image above

@ArsenLuca
Copy link
Author

In windows VS, it shows
image

@ArsenLuca
Copy link
Author

ArsenLuca commented Jul 4, 2018

@frotms
Also, in each run, different errors happen.
In one run, it happens that:

for (unsigned int lineID = 0; lineID < numOfFinalLine; lineID++){
lineIDInScaled = scaledLines[lineID].lineIDInScaled;
direction = edLineVec_[ZERO]->lineDirection_[lineIDInScaled];
singleLine.scaledCount = ZERO;
singleLine.direction = direction;
singleLine.lineLength = scaledLines[lineID].lineLength;
singleLine.salience = edLineVec_[ZERO]->lineSalience_[lineIDInScaled];
singleLine.numOfPixels = edLineVec_[ZERO]->lines_.sId[lineIDInScaled + 1] -
edLineVec_[ZERO]->lines_.sId[lineIDInScaled];

edLineVec_[ZERO]->lines_.sId has a size of 40, while lineIDInScaled is 39. So edLineVec_[ZERO]->lines_.sId[lineIDInScaled + 1] is out of range.

@frotms
Copy link
Owner

frotms commented Jul 4, 2018

I'll try later @ArsenLuca

@ArsenLuca
Copy link
Author

@frotms
I first resize the image to 640*640 and debug the codes.
It comes that in the following line:
lines.sId.resize(5 * edges.numOfEdges);
edges.numOfEdges is 8.
so edLineVec_[ZERO]->lines_.sId has the size of 40.

while in:
for (unsigned int lineID = 0; lineID < numOfFinalLine; lineID++){ lineIDInScaled = scaledLines[lineID].lineIDInScaled; direction = edLineVec_[ZERO]->lineDirection_[lineIDInScaled]; singleLine.scaledCount = ZERO; singleLine.direction = direction; singleLine.lineLength = scaledLines[lineID].lineLength; singleLine.salience = edLineVec_[ZERO]->lineSalience_[lineIDInScaled]; singleLine.numOfPixels = edLineVec_[ZERO]->lines_.sId[lineIDInScaled + 1] - edLineVec_[ZERO]->lines_.sId[lineIDInScaled];
numOfFinalLine is 93,
So when the loop comes at lineID == 39, lineIDInScaled is also 39, So edLineVec_[ZERO]->lines_.sId[lineIDInScaled + 1] is out of range.
I think lineIDInScaled+1 should be less than 5 * edges.numOfEdges and I don't know exactly why when using this image, 5 * edges.numOfEdges can be equal to lineIDInScaled+1

@ArsenLuca
Copy link
Author

@frotms
It seems that the problem is due to 5 * edges.numOfEdges is not enough for numOfFinalLine.
So why do you set the constant multiplier to be 5? And how to control 5 * edges.numOfEdges is larger than numOfFinalLine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants