-
Notifications
You must be signed in to change notification settings - Fork 558
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
[Bug] Visual Studio detects stack corruption in apriltag.c homography_compute2 #72
Comments
I encountered the same issue. Will there be an update of the code that fixes the problem? |
Could you attach an image saved in a lossless format ( |
Unfortunately I was not able to save the image where this happend (because the process crashed).
|
I originally used TIF but I guess the error will also show up in the PNGs |
I was able to reproduce this locally, use image magic to convert to pnm The problem as described above is the max index remaining -1 resulting in writes outside of the valid boundary of A later in the function. Using a value of -1 is obviously wrong especially when it's multiplied by 9 - this is why we're hitting the guard bytes in stack-protected binaries. However, I'm not sure what brings the algorithm to a better solution yet. The other trap door to watch out for is the DIV later by A. That is what this check is warning us about. I'm doing some reading and experimenting and will propose a PR that at least prevents both crash scenarios. |
I converted the graphics above (https://user-images.githubusercontent.com/83595887/118779876-c8936580-b88b-11eb-947b-48d38a0d3840.png) via Converted PNM image:
With AddressSanitizer enabled (
|
👍 |
In the example data by @hartter, this was caused by invalid values in Another case that could lead to a negative |
Visual Studio in Debug is telling me that the stack is getting corrupted in apriltag.c in homography_compute2(). See lines 435, 436.
double max_val = 0;
int max_val_idx = -1;
I confirm in the debugger that the invalid index (-1) for max_val_idx survives to be used as an index later in the function. So I simply changed the initial value of max_val to be -1.0 and the problem went away because the first iteration of the loop then assigns both values and max_val_idx is no longer -1.
The text was updated successfully, but these errors were encountered: